Skip to main content
Engineering LibreTexts

7.6: Linked Lists vs Arrays

  • Page ID
    34676
  • Advantages over arrays
    1) Dynamic size
    2) Ease of insertion/deletion

    Drawbacks:
    1) Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do binary search with linked lists efficiently with its default implementation. Read about it here.
    2) Extra memory space for a pointer is required with each element of the list.
    3) Not cache friendly. Since array elements are contiguous locations, there is locality of reference which is not there in case of linked lists.

    Representation:
    A linked list is represented by a pointer to the first node of the linked list. The first node is called the head. If the linked list is empty, then the value of the head is NULL.
    Each node in a list consists of at least two parts:
    1) Data
    2) Pointer (Or Reference) to the next node

    Adapted from:
    "Linked List | Set 1 (Introduction)" by ashwani khemani is licensed under CC BY-SA 4.0