Data Structure : Doubly Linked List

Summary


Introduction to Doubly linked list

Doubly linked list is a collection of nodes linked together in a sequential way. Each node of the list contains two parts (as in singly linked list) data part and the reference or address part. The basic structure of node is shown in the below image:
Doubly linked list node representation
Doubly linked list is almost similar to singly linked list except it contains two address or reference fields, where one of the address field contains reference of the next node and other contains reference of the previous node. First and last node of a linked list contains a terminator generally a NULL value, that determines the start and end of the list. Doubly linked list is sometimes also referred as bi-directional linked list since it allows traversal of nodes in both direction. The basic structure of a doubly linked list can be represented as:
Doubly linked list representation
Since doubly linked list allows the traversal of nodes in both direction hence we can keep track of both first and last nodes.

Basic structure of a doubly linked list

The basic structure of a doubly linked list contains a data field and two address fields. Here is how it can be represented in C programming language.
struct node {
    int data; //Data field
    struct node * prev; //Address of previous node
    struct node * next; //Address of next node
};

Advantages of Doubly linked list

Doubly linked list is one of the important data structures. Here are various advantages of doubly linked list.

Disadvantages of Doubly linked list

Not many but doubly linked list has few disadvantages also which can be listed below:


Applications/Uses of doubly linked list in real life

There are various application of doubly linked list in the real world. Some of them can be listed as:

Basic operations performed on Doubly linked list



Note: Deleting entire list, counting elements or searching an element in doubly linked list programs are similar to singly linked list programs.


Labels: , ,