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.
Working of a Doubly Linked List:
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. Doubly linked list allows backward traversing if required. All other functions are similar linked list.
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:
- Doubly linked list allows to traverse in both forward and backward directions.
- Deletion of the nodes can be done easily.
- Reversing of linked list is easy.
Disadvantages of Doubly Linked List:
- In a doubly linked list, each node has an extra pointer which requires extra space.
- Doubly linked list operations require more pointers to be handled hence, more time.
- Random access to elements is not allowed.