LinkedList


LinkedList is linear data structure like arrays. Unlike array, elements of linked list are not stored at contigous memory location. Pointers are used to locate elements in linked list.

Why LinkedList?

  1. Size of the array is fixed. So you must know the upper limit on the number of elements in advacne.
  2. Inserting new element in array is expensive, because room has to be created for the new elements and to create room exising elements have to shifted.

Advantage over Arrays

  1. Dynamic size
  2. Ease of insertion/deletion

Drawback

  1. Random access is not allowed. We have to access elements sequentially starting from the first node.
  2. Extra memory space for a pointer is required.