Ticker

6/recent/ticker-posts

Doubly Linked List

The doubly linked list is just like the simply linked list with a minor difference of storing the reference of the previous node in it. so in the doubly linked list we have nodes which contain 3 values - pointer to previous node, actual value, pointer to next node.

 Pointer to previous node just contains the address to the previous element in the list. 

So we could travel both forward and backward in the doubly linked list but we cant do that in the simply linked list.

prev- pointer to the previous node

next- pointer to next element

NULL <-- [prev],actual_value,[next] <--> [prev],next_value,[next] --> NULL


we have to understand that the first node 'the head node, its pointer to the previous value would point to NULL as there's no previous element to the head node. and we already know that the pointer to next node of last element of the list would also point to NULL.

the main feature of the doubly linked list is that we can travel in both forward and backward directions with help of previous node pointers.


the time complexity in all the cases that are addition, deletion, insertion and accessing the element is O(n). this is same as in all the cases in the simply linked list as for there operations we have to remap the references of the elements.

T


here's not much of a difference between time complexity in simply and doubly linked list.


So this is all about the doubly linked list you all have to know and make sure to follow our Blog.


Post a Comment

0 Comments