Professional Documents
Culture Documents
CP
CS
20
4
CP
CS
20
4
Linked List
Operations
CP Operations
CS
• Is Empty
20
4 • Traversing
• Modifying
• Searching
• Insertion
• Deletion
• Merging
3 Dr. Jonathan (Yahya) Cazalas Dr. Muhammad Umair Ramzan
Data Structures - I
“No Bonus” marks for this course anymore
CP
CS
20
4
Linked List
Operations
(Deletion)
10 null 10 null
• Value = 10
8 Dr. Jonathan (Yahya) Cazalas Dr. Muhammad Umair Ramzan
Data Structures - I
“No Bonus” marks for this course anymore
if (head.data == value)
4
head = head.next;
}
}
head
10 20 50 null
• Value = 10
10 Dr. Jonathan (Yahya) Cazalas Dr. Muhammad Umair Ramzan
Data Structures - I
“No Bonus” marks for this course anymore
if (head.data == value)
4
head = head.next;
}
}
head
10 20 50 null
• Value = 10
11 Dr. Jonathan (Yahya) Cazalas Dr. Muhammad Umair Ramzan
Data Structures - I
“No Bonus” marks for this course anymore
helpPt helpPt
head r r
CP 10 20 null 50 null
CS
• Traverse till 2nd last node
20 o helpPtr=head
4 o helpPtr.next.next != null
• Make helpPtr’s next point to null
o helpPtr.next = null
• Java garbage collector will
remove the last node
CP
CS
20
4
Linked List
Operations
(Merging)
4 helpPtr.next = head2
return head1;
}
helpPt helpPt helpPt helpPt
head1 r r r r
10 20 50 60 null
head2
70 80 90 100 null
CP
CS
20
4