Circular Linked List
Circular Linked List
This drawback can be overcome by making a small change, and this change is without
any additional data structure.
In a singly linear list, SLL, the last nodes link field is set to Null. Instead of that, store the
address of the first node of the list in that link field.
This change will make the last node point to the first node of the list.
Such a linked list is called circular linked list , shown in Fig. 6.34.
Circular linked list with header node is a solution to a problem of checking end of traversal as
(while(x->link != Head));
This would enter an infinite loop.
So, we can use a circular linked list with header node as shown in Fig. If the head pointer points to the last
node, then a node can easily be inserted at the front and also at the rear of the list.
The above Figure represents the doubly circular linked list without a header node.
Figure represents doubly circular linked list with header node. Header node may store some
relevant information of the list.