The cons of array over a linked list

Array data structure is simple to use and it is supported by almost all programming languages. It is very simple to understand and time to access any element from an array is constant. An array element can be accessed by a[i], where ´a´ is a name of the array and i is the index.

Compiler maps a[i] to its physical location in memory. Address of a[i] is given by starting address of a + i* size of array elements in bytes. This mapping is carried out in constant time, irrespective of which element is accessed. Array data struture suffers from some severe limitations:

Size of an array is defined at the time of programming or compile time.

Insertion and deletion is time consuming.

Requires contiguous memory.

First, the size of an array has to be defined when the program is being written and its space is calculated during compilation of the program. This means that the programmer has to take a decision regarding the maximum size of data. If the actual amount of data stored is less than the maximum size, a good amount of memory will be waited and on the other hand a larger sample of data can not be handled. To avoid the linear cost of insertion and deletion, we need to ensure that the list is not stored contiguously, since otherwise entire parts of list will need to be moved.