We have discussed singly and doubly linked lists in the following posts.
Circular linked list is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list.
Advantages of Circular Linked Lists:
1) Any node can be a starting point. We can traverse the whole list by starting from any point. We just need to stop when the first visited node is visited again.
2) Useful for implementation of queue. Unlike this implementation, we don’t need to maintain two pointers for front and rear if we use circular linked list. We can maintain a pointer to the last inserted node and front can always be obtained as next of last.
3) Circular lists are useful in applications to repeatedly go around the list. For example, when multiple applications are running on a PC, it is common for the operating system to put the running applications on a list and then to cycle through them, giving each of them a slice of time to execute, and then making them wait while the CPU is given to another application. It is convenient for the operating system to use a circular list so that when it reaches the end of the list it can cycle around to the front of the list.
4) Circular Doubly Linked Lists are used for implementation of advanced data structures like Fibonacci Heap.
Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Circular Queue | Set 2 (Circular Linked List Implementation)
- Doubly Circular Linked List | Set 1 (Introduction and Insertion)
- Convert singly linked list into circular linked list
- Check if a linked list is Circular Linked List
- Applications of linked list data structure
- Doubly Circular Linked List | Set 2 (Deletion)
- Circular Linked List | Set 2 (Traversal)
- Convert a given Binary Tree to Circular Doubly Linked List | Set 2
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Exchange first and last nodes in Circular Linked List
- Find minimum and maximum elements in singly Circular Linked List
- Sum and Product of the nodes of a Circular Singly Linked List which are divisible by K
- Sum and Product of nodes with value as even digit sum in Circular Linked List
- Remove all even parity nodes from a Doubly and Circular Singly Linked List
- Split a Circular Linked List into two halves
- Sorted insert for circular linked list
- Circular Singly Linked List | Insertion
- Count nodes in Circular linked list
- Josephus Circle using circular linked list