What is a Circular linked list?
A circular linked is very similar to a singly linked list, the only difference is in the singly linked list the last node of the list point to null but in the circular linked list the last node of the list point to the address of the head. This type of list is known as a circular linked list.
We can traverse all nodes starting from the head and stop when the next node is pointing to the head which indicates we have reached the last node.
Below is the figure of how circular linked list looks
While traversing the circular linked list, we have to break the loop if we find the next of the last node is equal to the head other we can go into an infinite loop.
Advantage of Circular linked list
- We can go to any node from any node in the Circular linked list which was not possible in the singly linked list if we reached the last node.
- Easily we can go to head from the last node
- In a circular list, any node can be starting point means we can traverse each node from any point.
Disadvantage of Circular linked list
- If not handled proper validation then code may go in an infinite loop.
- Not easy to reverse a circular linked list.
- For the implementation perspective to insert at the beginning we have to traverse the complete list to find the last node.
- Harder to find the end of the list and loop control.
Applications of the Circular Linked List
- In Implementation of round-robin scheduling in system processes
- In the implementation of circular scheduling in high-speed graphics
- In computer networks to schedule Token rings.
To display units like shop boards that require continuous traversal of data.
Operations can be performed on a Circular linked list
- Traversal of circular linked list
- Insertion a node at the beginning, at the end, and at a given location.
- Deletion a node from the beginning, end, and given location
- Searching a data in a circular list