Memory Array Organizations
Memory Array Organizations
A memory array is a linear data structure that stores a collection of similar data types at
contiguous locations in a computer's memory. Memory arrays are categorized as one-
dimensional arrays and multiple-dimensional arrays. Arrays are among the oldest data
structures and are used in almost every computer program.
One-dimensional Arrays
A one-dimensional array, also known as a single dimension array, is a linear data structure array
that requires only one subscript specification to indicate a single array element. It is a collection
of variables related to one another and have similar data types. A one-dimensional array
enables random access, and all the elements can be retrieved with the support of their index.
These types of arrays are popular in programming.
Multiple-dimensional Arrays
A multiple-dimensional array is a linear data structure array with two subscripts. Like a one-
dimensional array, it also allows random access, and all the elements can be retrieved with the
support of their index. A multiple-dimensional array can be seen as a collection of 1D arrays
known as a matrix. The dimensions of multiple-dimensional arrays can be increased from 2 to 3
and so forth. The simplest form of multiple-dimensional array is a two-dimensional array,
usually denoted as 2D.
Arrays are often represented with diagrams that represent their memory use. The
diagram below is one typical way to represent the memory used by an array.
Each box represents the amount of memory needed to hold one array element. For
ints this is usually 4 bytes. We can write the value of an element inside the box.
Pointers hold the memory address of other data and are represented by a black
disk with an arrow pointing to the data it references.
The actual array variable, a in this example, is a pointer to the memory for all of its
elements. A common shortcut is to omit writing the array variable, and write only
the elements that hold the data because these are usually the focus of attention.
Sometimes the cells are written horizontally, especially when showing C-strings
(arrays of chararcters).
or simply
or just
Array indexes always start from 0. Hence the first element of the 2D array is at
intArr[0][0]. This is the first row-first column element. Since it is an integer
array, it occupies 4 bytes of space. Next memory space is occupied by the
second element of the first row, i.e.; intArr [0][1] – first row-second column
element. This continues till all the first row elements are occupied in the
memory. Next it picks the second row elements and is placed in the same way
as first row. This goes on till all the elements of the array are occupies the
memory like below. This is how it is placed in the memory. But seeing the
memory address or the value stored in the memory we cannot predict which is
the first row or second row or so.
Total size/ memory
occupied by 2D array is calculated as