Write a function to Delete a node from Doubly Linked List ?
- In a single linked list, every node has link to its next node in the sequence.
- So, we can traverse from one node to another node only in one direction and we cannot traverse back. We can solve this kind of problem by using double linked list.
- Double linked list is a sequence of elements in which every element has links to its previous element and next element in the sequence.
- In double linked list, every node has link to its previous node and next node. So, we can traverse forward by using next field and can traverse backward by using previous field.
Algorithm
Sample Code in C++
Output
Time Complexity
- O(n), in worst case where n is the number of nodes in the doubly linked list.