Array
Array
stored at contiguous memory locations. It’s one of the most popular and simple
data structures and is often used to implement other data structures.
Each item in an array is indexed starting with 0..
Representation of Array
Why Array Data Structures is needed?
Assume there is a class of five students and if we have to keep records of their
marks in examination then, we can do this by declaring five variables individual
and keeping track of records but what if the number of students becomes very
large, it would be challenging to manipulate and maintain the data.
What it means is that, we can use normal variables (v1, v2, v3, ..) when we have a
small number of objects. But if we want to store a large number of instances, it
becomes difficult to manage them with normal variables. The idea of an array is
to represent many instances in one variable..
Types of arrays:
There
here are majorly two types of arrays:
One-dimensional
dimensional array (1(1-D arrays): You can imagine a 1d array as a row,
where elements are stored one after another.
1D array
Two-dimensional
dimensional array: 2-D Multidimensional arrays can be considered as an
array of arrays or as a matrix consisting of rows and columns.
2D array
Three-dimensional
dimensional array: A 3-D Multidimensional array contains three
dimensions,
ensions, so it can be considered an array of two
two-dimensional
dimensional arrays.
3D array