0% found this document useful (0 votes)
17 views2 pages

Circular Linked List

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Circular Linked List

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Circular Linked List(CLL)

 CLL is a solution to the drawbacks of SLL


 Unlike DLL, CLL does not require additional link field.
 Drawbacks of SLL
 In SLL, each node provides information about where the next node is. It has no
knowledge about where the previous node is.
 If we are at the ith node in the list currently, then to access the (i -1)th node or (i -2)th
node, we have to traverse the list right from the first node.
 In addition, it is not possible to delete the ith node given only a pointer to the ith node.
 It is also not possible to insert a node before the ith node given only a pointer to the ith
node.

 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.

 In CLL, it is possible to reach from any


node to any other node in the list.
 CLL list is used to keep track of free space (unused nodes) in memory.
 In a CLL, traversal can be continued from current node.
 The two primary applications of circular list is time slicing and memory management.
 We can have a circular SLL or DLL. Both alternatives are possible.
 Similarly, CLL could be with or without header nodes.

Singly circular list


 If the pointer head points to the first node of the list, accessing the last node (for insertion or
deletion at the end of the list )would require traversing all the nodes in list.
 Instead if the pointer head points to the last node of the list. It makes easy to access the first
node. There by insertion and deletion operations at the beginning or at the end would be easy.

(Head>next) gives us the address of the first node.

Circular Linked List with Header Node

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.

Doubly Circular Linked List


In doubly circular linked list, the last node’s next link is set to the first node of the list and
the first node’s previous link is set to the last node of the list. This gives access to the last
node directly from the first node.

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.

You might also like