Difference between Array and Linked List

Both Array and Linked List are used to store the data having a similar type, but the difference is that array takes memory locations in contiguous fashion at compile-time, i.e. when we declare of an array, while elements of the linked list take memory, not in contiguous fashion and takes memory at runtime.

Array VS Linked List

  1. An array is a data structure that contains elements of similar data type elements. Whereas the Linked list is a data structure that contains a collection of unordered linked elements known as nodes.
  2. In an array, we can perform random access of the element, but in a linked list we cannot perform the random access, we have to do it sequentially.
  3. In an array, each element has an index number, So that we can access any element by its index number. But in a linked list all elements are connected sequentially, so we have to traverse each element until we find a similar match.
  4. Element access in an array is fast, but in a Linked list, it takes more time, so it is a little bit slower.
  5. Operations like insertion and deletion of an element in arrays take more time as compared to the Linked lists. We can perform this operation in a linked list faster.
  6. The size of an array is fixed, and we cannot increase it at runtime, but the size of the linked list is dynamic we can expand it at runtime as per requirement.
  7. In an array, memory is assigned during the compile time so that size of an array is fixed during the execution of the program while in a Linked list memory is allocated during execution or runtime.
  8. In array memory to the elements of the array is allocated sequentially in the memory whereas in Linked list memory is assigned to the node of linked list is random.
  9. If our requirement of memory is defined or fixed initially, then an array is a better option for our program, but when it is not decided, then a linked list is a better option.
  10. In array memory utilization is inefficient whereas in linked list memory utilization is efficient. 

Share on