Arrays are basic data structures used to store collections of data sequentially.

Features of arrays are:

  • Elements can be accessed randomly (identified by indexes)

  • Can have one or more dimensions

  • Fixed capacity

The capacity of an array is the maximum number of items it can hold. The length is the number of items in the array.

The capacity of an array is specified when it is created. The memory needed for the maximum size of the array is reserved, regardless of the number of items in it. The default value of empty array indexes is language-specific.

Dynamic Arrays

Dynamic arrays are the same as arrays, but with variable capacity. An example of this is the vector type in C++.

2D Arrays

2D arrays are used to represent rectangular grids. They are usually implemented as an array of arrays.

In some languages, these are implemented internally as one-dimensional arrays, and in some others there's no multidimensional arrays at all.

Last updated