DATA STRUCTURES AND ALGORITHM
Dr. Usman Ashraf
Double Linked List
Analysis of Singly Linked-List
moving the current pointer back one node requires traversing the list from the start until the node whose next pointer points to current node.
2
Introduction
3
Doubly Linked List
4
*Previous
*Next
Data
A Singly Linked List
5
Head
Head
A Doubly Linked List
Comparison of Linked Lists
class Node {
int data;
Node* next;
};
class Node {
Node *previous;
int data;
Node *next;
public:
Node *getPrevious() {
return previous; };
void setPrevious(Node *prev)
{ this->previous= prev; };
};
6
Insertion
7
Insertion
8
Deletion
9
Deletion
10
Advantages of Doubly Linked List
11
Disadvantages
12