Linked list vs Array

Arrays and Linked list are used to store linear data of similar types. In this post we will learn differences between arrays and linked list (Linked List vs Arrays).

Differences – (Linked List vs Array)

1) Arrays are assigned with contiguous memory location during compile time whereas in the linked list the memory is allocated at run time whenever a new element is added to it.

2) Arrays are fixed in size means so we have to provide the size limit of an array during declaration of array. Allocated memory is equal to the size of array irrespective of the usage. But this is not the case in Linked list, the size of linked list is variable and can be change at run time when element is added or deleted.

3) Insertion and deletion in array is expensive as we have to shift the array elements when we add or delete an element. Linked list has advantage over the array here, as insertion and deletion of elements are easy in linked list.

4) Random access of element is not possible in linked list we have to always start from the head of the linked list to access any element in the linked list whereas Arrays allow random access.

5) For every element of linked list we have to maintain an extra space for pointers.

Leave a Reply

Your email address will not be published. Required fields are marked *