Open In App

Applications, Advantages and Disadvantages of Doubly Linked List

Last Updated : 16 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Doubly linked list is a type of linked list in which nodes contains information and two pointers i.e. left pointer and right pointer. The left pointer in the doubly linked list points to the previous node and the right pointer points to the next node in the linked list. The first node of the doubly linked list has NULL in its left pointer and the last node of the doubly linked list has NULL in its right pointer. It is also known as a two-way linked list as there are two pointers. The benefit of this doubly linked list is that now we can navigate in both directions.  Also, we can delete a node without containing the previous node’s address as every node has a left pointer that points to its previous node.

DOUBLY LINKED LIST

Working of a Doubly Linked List:

A Doubly linked list node contains three fields: 

  • Left pointer,  
  • Information and 
  • Right pointer. 

The left pointer points to the node which is before the current node and the right pointer points to the node after the current node. A Doubly linked list allows backward traversing if required. All other functions are similar to linked list.

It is different from the normal linked list by allowing the bidirectional traversal which in turn reduces the time complexity of any operation. 

characteristics of a doubly linked list:

  • Each node contains two pointers: one pointing to the previous node and one pointing to the next node.
  • The first node’s previous pointer points to null and the last node’s next pointer points to null.
  • The linked list can be traversed in both forward and backward directions.
  • The size of the linked list can be dynamically adjusted based on the number of elements added or removed.
  • Insertions and deletions can be performed in constant time at both the beginning and the end of the list.
  • Access and search operations have O(n) time complexity, where n is the number of elements in the list.
  • It requires more memory compared to a singly linked list, as each node has two pointers.

Insertion:
Insertion into a doubly-linked list has three cases that are as follows:

  • Inserting a new node before the head of the linked list i.e. at the beginning.
  • Inserting a new node after the tail of the linked list i.e. at the end.
  • Inserting a new node at a specific position.

Deletion:
Deletion into a doubly-linked list has three cases that are as follows:

  • Deleting the first node.
  • Deleting the last node.
  • Deleting a specific node.
     

Applications of Doubly Linked List:

  • Doubly linked list can be used in navigation systems where both forward and backward traversal is required.
  • It can be used to implement different tree data structures.
  • It can be used to implement undo/redo operations. 

Real-Time Applications of Doubly Linked List:

  • Doubly linked lists are used in web page navigation in both forward and backward directions.
  • It can be used in games like a deck of cards. 

Advantages of Doubly Linked List:

  • Efficient traversal in both forward and backward directions: With a doubly linked list, you can traverse the list in both forward and backward directions, which can be useful in certain applications.
  • Dynamic size adjustment: The size of the list can be easily adjusted based on the number of elements added or removed, making it a flexible data structure.
  • Constant-time insertions and deletions: Insertions and deletions can be performed in constant time at both the beginning and the end of the list.
  • Easy to implement: The doubly linked list is relatively easy to implement, compared to other data structures like arrays or trees.
  • Efficient memory utilization: The doubly linked list can be used to manage memory efficiently, as nodes can be easily added or removed as needed.

Disadvantages of Doubly Linked List:

  • More memory usage: Each node in a doubly linked list requires two pointers (previous and next), resulting in higher memory usage compared to a singly linked list.
  • Slower access and search times: Access and search operations have O(n) time complexity, where n is the number of elements in the list. This can result in slower performance compared to other data structures like arrays or trees, especially for large lists.
  • Complex implementation: The implementation of certain operations, such as sorting, can be more complex compared to arrays or other data structures.
  • Higher overhead for updates: Updates to the list, such as inserting or deleting elements, can be more time-consuming compared to arrays or other data structures.
  • Pointer management: The management of pointers in a doubly linked list can be more complex compared to other data structures, and mistakes in pointer management can result in serious errors in the program.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads