Doubly linked list data structure

In a double linked list, every list of the element has both a reference to the next element and reference to the prior element. Hence doubly linked list can be traversed in both directions and two pointers are used. Diagrammatically a node is represented as,

RLINK contains the address of the succeeding node and LLINK contains the address of the predecessor node. Data fields contain actual data.

The structure definition for each node is as follows:

struct node {
  struct node* rlink
  int data;
  struct node* llink;
};

The leftmost and rightmost nodes of doubly linked lists are pointed by L & R pointers respectively. 

doubly linked list Advantage

doubly linked list Disadvantages

Primitive Operations on a doubly linked list

Insertion and deletion are two primitive operations performed on the double list.

Inserting a Node at the Beginning

Example:

Inserting a Node at End

 

Insert a Node at any Position

To insert a new node at any position i, traverse the linked list up to (i-1)th position and perform the following operations:

Deletion at the Beginning

Deleting a node in middle (at position i)