What is Doubly Linked List ? - data structure tutorial

What is Doubly Linked List ? - data structure tutorial

It is strongly recommended that you must have knowledge of linked lists before. If you dont have any knowledge of linked list then click in this link .

Doubly Linked List is a variety of Linked list wherein navigation is possible in the two different ways, either forward and backward effectively as compared with Single Linked List. 

Therefore, in a doubly-linked list, a node comprises of three sections: node information, a pointer to the next node (next pointer), a pointer to the previous node (past pointer). 

A doubly linked list containing three nodes having numbers from 1 to 3 in their information part, is shown below.


What is Doubly Linked List ? - data structure tutorial



Advantages over the singly linked list


1) A DLL can be navigated in both forward and reverse way.

2) The deletion operation in DLL is more effective if a pointer to the node to be deleted is given.

     In a singly linked list, to delete a node, a pointer to the previous node is required.

     To get this past node, here and there the list is traversed.

     In DLL, we can get the previous node by utilizing previous pointer.

3) We can rapidly add another node before a given node (



Disadvantages of over singly Linked List


1)    

2)    

In C++, structure of a node in doubly linked list can be given as :

1.      

2.      

3.      

4.      

5.      

6.      


Basic Operations

The following are the basic operations supported by a list.

·     

·     


Insertion Operation

A node can be added in four ways


Add a node at the front



What is Doubly Linked List ? - data structure tutorial




Add a node after a given node



What is Doubly Linked List ? - data structure tutorial




3) Add a node at the end


What is Doubly Linked List ? - data structure tutorial









Add a node before a given node





Deletion Operation

A node can be added in 2 ways:

1.      

2.      



Delete a node from beginning of a Doubly Linked List


What is Doubly Linked List ? - data structure tutorial







Deletion in doubly linked list at the end


What is Doubly Linked List ? - data structure tutorial






 Some commonly asked problems on doubly linked lists in interviews (What is Doubly Linked List ? - data structure tutorial):

1. WAP to find middle element of a doubly linked list.
2. WAP to find pair with given sum in a doubly linked list.
3. WAP to reverse a doubly linked list.


Post a Comment (0)
Previous Post Next Post