Arrays in Data Structure | Declaration,
Initialization, Memory representation
At runtime, arrays can be initialized using loops and predefined functions
such as scanner. In the upcoming video, the methods for taking data from
a user and storing it in an array will be discussed, followed by topics on
inserting data and traversing arrays, including types of operations on a 1D
array and time taken for each operation. The video will also cover the
concept of a 2D array and how it can be accessed. Faerie explains the
need and concept of arrays in detail, highlighting how arrays can be
declared, initialized, and represented in memory. An array is a storage
space for multiple values, and while a variable can only store one value,
an array can store multiple values at once. For example, to store data for
60 students, one would need to take the approach of an array, rather than
creating 60 individual variables. In order to create an array, one must
declare the data type, array name, and size. The size must be a constant
and specific to the language being used. The syntax for array declaration
may differ depending on the programming language, but the concept
remains the same. Additionally, the memory representation of an array
and how data is stored in memory will be covered in the upcoming videos.
Furthermore, the upcoming video will focus on 1D arrays, with an example
array named variable B with a set size. The methods for accessing and
using variable B will be discussed, including the process of representing it
in memory.
Data is to be represented in memory or the memory representation of an
array. The need for ferry and how to deal with it is explained. The concept
of an array was introduced because of the large amount of data that
needed to be processed. The declaration syntax for arrays may vary
depending on the programming language being used. All elements in an
array are stored in consecutive or continuous locations one after another
in memory. The elements are stored in successive locations, and the
index starts from zero. The size of the array cannot be changed at
runtime, and at compile time, you specify what elements you want in the
array. During runtime, you can only store a fixed amount of elements. In
the case of a 5 by 4 array, which is a fixed-size array, 20 bytes are
allocated depending on the memory manager used. The memory manager
allocates consecutive bytes in successive locations for storing the
elements of the array. Dynamic arrays and other programming languages'
syntax for array declaration are discussed in later sections. The 6 in the
array is first converted to binary form and then stored in four bytes. To
calculate the address for the location, the formula is base address plus the
I value into the size of the array, which is a data type of 4 bytes. The
drawback of arrays is the wastage of space. The array follows the random
access method, meaning you can access any data with constant time if
you know the base address.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller thecarguy177. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $8.19. You're not tied to anything after your purchase.