Linked list disadvantages


Drawbacks / Disadvantages of Linked List

Disadvantages of Linked List in C Programming

1. Wastage of Memory -

  1. Pointer Requires extra memory for storage.
  2. Suppose we want to store 3 integer data items then we have to allocate memory -

in case of array -

Memory Required in Array = 3 Integer * Size
                         = 3 * 2 bytes
                         = 6 bytes

in case of array -

Memory Required in LL    = 3 Integer * Size of Node
                         = 3 * Size of Node Structure
                         = 3 * Size(data + address pointer)
                         = 3 * (2 bytes + x bytes)
                         = 6 bytes + 3x bytes

*x is size of complete node structure it may vary

2. No Random Access

  1. In array we can access nth element easily just by using a[n].
  2. In Linked list no random access is given to user, we have to access each node sequentially.
  3. Suppose we have to access nth node then we have to traverse linked list n times.

Suppose Element is present at the starting location then -

We can access element in first Attempt

Suppose Element is present at the Last location then -

We can access element in last Attempt

3 . Time Complexity

  1. Array can be randomly accessed , while the Linked list cannot be accessed Randomly
  2. Individual nodes are not stored in the contiguous memory Locations.
  3. Access time for Individual Element is O(n) whereas in Array it is O(1).

4. Reverse Traversing is difficult

  1. In case if we are using singly linked list then it is very difficult to traverse linked list from end.
  2. If using doubly linked list then though it becomes easier to traverse from end but still it increases again storage space for back pointer.

5. Heap Space Restriction

  1. Whenever memory is dynamically allocated , It utilizes memory from heap.
  2. Memory is allocated to Linked List at run time if and only if there is space available in heap.
  3. If there is insufficient space in heap then it won’t create any memory.