Arrays

The Array is the simplest data structure there is. Some might not even call it a data structure per se because arrays are pretty much dependent on the language of implementation. For example, in C, an array is an ordered set of homogenous elements of same size laid out in memory contiguously; while, in PHP, arrays are ordered set of homogenous/heterogenous elements of different sizes and can also act as hash tables or dictionaries. However, PHP is an exception in this case. In most languages, arrays are ordered sets of homogenous items laid out contiguously. Remember though that memory layouts are an implementation detail of the language; that being said, they might not be contiguous in the computer memory all the time.

This language specific implementation is one of the reasons why an array is not listed as a Data Structure in many books. There is another reason for it - Array can itself be made to act as one of the other data structures such as stacks, queues, matrices and sets.

General Definition

So what is an array from the perspective of a Data Structure?

Array is a limited, ordered set of same-sized elements laid out one after another in sequence.

As we will see shortly, arrays have numerous uses. Many list-based data structures like Queues and Stacks can be implemented using Array. They are also more or less a ‘natural’ way for a computer to access data.

Updated: