Advantages and Disadvantages of Linked List

Introduction

The linked list is one of the most important concept and data structure to learn while preparing for interviews. Having a good grasp of Linked Lists can be a huge plus point in a coding interview.

A Linked List is a linear data structure. Unlike arrays, the elements are not stored in contiguous locations. The Linked List elements are linked using pointers.

Advantages of Linked List

  • Dynamic Data Structure - Linked List being a dynamic data structure has the ability to shrink and grow at the runtime by deallocating or allocating memory. So, there is no need for initial size.
  • No Memory Wastage - As the size of a linked list can grow or shrink at runtime, so there is no memory wastage. Only the required memory is allocated.
  • Implementation - Some very helpful data structures like queues and stacks can easily be implemented using a Linked List.
  • Insertion and Deletion Operation - In a Linked List, insertion and deletion operations are quite easy, as there is no need to shift every element after insertion or deletion. Only the address present in the pointers needs to be updated.

Disadvantages of Linked List

  • Memory Usage - The memory required by a linked list is more than the memory required by an array, as a pointer to store the address of the next element is required.
  • Traversal - Traversing a linked list is a bit more time-consuming when compared to an array, as we do not have direct access to an element. Suppose we have to access a node at position x. To access node x, we have to traverse through all the nodes before it.
  • Reverse Traversal - In a singly linked list, reverse traversal is not possible, as every node stores only the address of the next node. In the case of a doubly-linked list, reverse traversal is possible, but it consumes more memory, as we have to allocate extra memory to store the previous pointer.
  • Random Access - Random access is not possible in a Linked List.

So, in this article, we have tried to explain the advantages and disadvantages of a linked list. If you want to solve more questions on Linked List, which are curated by our expert mentors at PrepBytes, you can follow this link Linked List.

Previous post Program to find the size of Doubly Linked List
Next post Partitioning a linked list around a given value and keeping the original order

Leave a Reply

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