Lecture 3 - Doubly Linked List
Lecture 3 - Doubly Linked List
Lecture 3 - Doubly Linked List
Lecture 3
Computer Science
Introduction
• The singly linked list contains only one pointer
field i.e. every node holds an address of next
node.
Computer Science
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 .
Computer Science
A Singly Linked List
Head
Head
Computer Science
Comparison of Linked Lists
• Linked list
struct Node {
int data;
Node* next;
};
• Doubly linked list
struct Node {
Node *previous;
int data;
Node *next;
};
Computer Science
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.
Computer Science
Insertion
Computer Science
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.
Computer Science
Deletion
Computer Science
Advantages of Doubly Linked List
Computer Science
Disadvantages
Computer Science