![]() |
VOOZH | about |
An array is a collection of items of the same variable type that are stored at contiguous memory locations. It is one of the most popular and simple data structures used in programming.
In an array, all the elements or their references are stored in contiguous memory locations. This allows for efficient access and manipulation of elements.
Arrays can be declared in various ways in different languages. For better illustration, below are some language-specific array declarations:
Arrays can be initialized in different ways in different languages. Below are some language-specific array initialization:
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. So we use an array of students.
Arrays can be classified in two ways:
1. Fixed Sized Arrays
2. Dynamic Sized Arrays
The size of the array changes as per user requirements during execution of code so the coders do not have to worry about sizes. They can add and removed the elements as per the need. The memory is mostly dynamically allocated and de-allocated in these arrays.
1. One-dimensional Array(1-D Array): You can imagine a 1d array as a row, where elements are stored one after another.
👁 One-Dimensional-Array(1-D-Array)
2. Multi-dimensional Array: A multi-dimensional array is an array with more than one dimension. We can use multidimensional array to store complex data in the form of tables, etc. We can have 2-D arrays, 3-D arrays, 4-D arrays and so on.
To read more about Matrix Refer, Matrix Data Structure
👁 Two-Dimensional-Array(2-D-Array-or-Matrix)
👁 Three-Dimensional-Array(3-D-Array)