L5 Linked List
L5 Linked List
Linked List
Doubly Linked List & Deletion
Dipannita Biswas
Md Mehrab Hossain Opi
Introduction 2
• Today we will learn how to remove a node from a linked list.
• But instead of using singly linked list, we will use doubly linked list
today.
struct node{
int data;
node *prev, *next;
};
Free
Initialize
Set
Traverse
next
the memory
cur
of
to ‘prev’
find
withthe
of
head
of last
tail
cur node
to null.
cur
Suppose
Deallocate
Set we
cur.prev.next
cur.next.prev
want
thetomemory
delete
to cur.next
cur.prev
the
of cur
value 3
head = 0x23
0x12
Deallocate
Sethead
Set Set memory
head.prev
cur
= = of cur
to null
head.next
head
0 1 2 0 3 6 4 0
Output
1
0 3 0 0
3
Input
[1,2,3,4,5,6,7,8,9]
Output
[1,6,2,7,3,8,4,9,5]
Thank You