Last Updated: 06 October, 2024 5 Mins
In this Linked List tutorial, we will see all about the delete operation in a single linked list. In the delete operation, we will remove an existing node from the linked list from any position.
In a Singly Linked List, we can delete a node at the following positions:
From the beginning of the linked list.
From middle of the linked list.
From the end of the linked list.
In the below given example we will see how to delete an existing node from the beginning or front the linked list.
Output
Original Linked List data:
10 -> 20 -> 30 -> 40 -> null
After deleting head, Linked List data:
20 -> 30 -> 40 -> null
In the below given example we will see how to delete an existing node from the any position of the linked list.
Output
Original Linked List data:
10 -> 20 -> 30 -> 40 -> 50 -> null
After deletion, Linked List data:
10 -> 20 -> 40 -> 50 -> null
In the below given example we will see how to delete an existing node from the end or last the linked list.
Output
Original Linked List data:
10 -> 20 -> 30 -> 40 -> null
After removing last node, Linked List data:
10 -> 20 -> 30 -> null
That's all, guys. I hope this article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com