0% found this document useful (0 votes)
20 views18 pages

9-DSA-Doubly Linked Lists

Uploaded by

seharamjadnuml
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views18 pages

9-DSA-Doubly Linked Lists

Uploaded by

seharamjadnuml
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

DATA STRUCTURES

Doubly Linked List


Introduction
• The singly linked list contains only one pointer
field i.e. every node holds an address of next
node.

• The singly linked list is uni-directional i.e. we


can only move from one node to its successor.

• This limitation can be overcome by Doubly


linked list.
Doubly Linked List
• In Doubly linked list, each node has two
pointers.
• One pointer to its successor (NULL if there is
none) and one pointer to its predecessor (NULL
if there is none).
• These pointers enable bi-directional traversing .
*Previous Data *Next
A Singly Linked List
Head

A Doubly Linked List

Head
Comparison of Linked Lists
• Linked list
struct Node {
int data;
Node* next;
};
• Doubly linked list
struct Node {
Node *previous;
int data;
Node *next;
};
Insertion
• In insertion process, element can be inserted in three
different places
– At the beginning of the list
– At the end of the list
– At the specified position.

• To insert a node in doubly linked list, you must update


pointers in both predecessor and successor nodes.
Insertion
Deletion
• In deletion process, element can be deleted from three
different places
– From the beginning of the list
– From the end of the list
– From the specified position in the list.

• When the node is deleted, the memory allocated to that


node is released and the previous and next nodes of that
node are linked
Deletion
Advantages of Doubly Linked List

1. The doubly linked list is bi-directional, i.e. it can


be traversed in both backward and forward
direction.
2. The operations such as insertion, deletion and
searching can be done from both ends.
3. Predecessor and successor of any element can
be searched quickly
Disadvantages

1. It consume more memory space.


2. There is a large pointer adjustment during insertion and
deletion of element.
3. It consumes more time for few basic list operations.

You might also like