- 0
Notifications Mark All Read
- Login
- Get Prime
Advantages, Disadvantages, and uses of Doubly Linked List
Advantages and disadvantages of Doubly linked list
Today in this page we will be discussing about Advantages and disadvantages of Doubly linked list.
A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.
Why Doubly Linked List?
Advantages
In case of singly linked list it is important to keep one more pointer pointing to the nide just before the node we want.
The temp is pointing to the first node but let’s say we have 5 modes in the list and our target is to delete the third node then in that case, the temp has to move one step forward. that means traversal is required (Time complexity O(n) )
In case of doubly linked list, deleting the intermediate node is very easy. There is no need keep an extra pointer to delete the intermediate node because it is always possible to reach the previous node from the current node to be deleted.
Inserting a new node before a given node is easier in doubly linked list.
In case of Singly Linked List, we need a pointer to the previous node in order to add a new node before the given node. Similar to deletion.
Currently, temp is pointing to the first node but imagine if we have ten nodes in the list, and our target is to add a node before the ninth node, then a pointer to the eighth node is required. This means traversal is required. Thus, insertion before a given node requires lot of work.
In case of doubly linked list, inserting a new node before the given node is very easy because we can always reach a node before the given node.
Disadvantages
- It uses extra memory when compared to the array and singly linked list.
- Since elements in memory are stored randomly, therefore the elements are accessed sequentially no direct access is allowed.
Uses of Doubly linked list
- It is used in the navigation systems where front and back navigation is required.
- It is used by the browser to implement backward and forward navigation of visited web pages that is a back and forward button.
- It is also used to represent a classic game deck of cards.
- It is also used by various applications to implement undo and redo functionality.
Login/Signup to comment