Linked List Operations
Traverse, Insert, Delete, Search and Sort
Before learn about linked list operations, make sure to know about Linked List first.
Things to remember
headpoints to the first node of the linked listnextpointer of the last node isNULL, so if the next current node isNULL, we have reached the end of the linked list.
Node structure -
All operations
- Traverse - Display all elements
- Insert - At the beginning, end, and a given position
- Delete - From the beginning, end, and a given position
- Search - Find a value in the list
- Sort - Sort the linked list using Merge Sort
Traverse a Linked List
Insert elements to a Linked List
We can add elements to either the beginning, middle, end or a specific position.
1. Insert at the beginning
2. Insert at the end
3. Insert at the middle
4. Insert at a Specific Position
Delete from a Linked List
We can delete either from the beginning, end or from a specific position.