Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

CIRCULARLY LINKED

LIST
What is circularly linked list:
• In single linked list, every node points to its next node in the sequence
and the last node points NULL.
• But in circular linked list, every node points to its next node in the
sequence but the last node points to the first node in the list.
• That means circular linked list is similar to the single linked list except
that the last node points to the first node in the list
Singly Linked List as Circular

• In singly linked list, the next pointer of the last node points to the first
node.
Doubly Linked List as Circular
• In doubly linked list, the next pointer of the last node points to the first
node and the previous pointer of the first node points to the last node
making the circular in both directions.

• As per the above illustration, following are the important points to be


considered.
• The last link's next points to the first link of the list in both cases of singly
as well as doubly linked list.
• The first link's previous points to the last of the list in case of doubly linked
list.
Advantages of Circular Linked Lists:
• 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.
• Useful for implementation of queue.
• 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.
• Circular Doubly Linked Lists are used for implementation of advanced data
structures like Fibonacci Heap.
Operations on circularly linked list:
Create a circularly linked list
Display the elements in the circular linked list
Insert an element in the circular linked list
Delete an element in the circular linked list
Searching an element in the list
1.Creation of
circularly linked list
2.Display of all nodes in CLL:
3.Insertion of a node in the circular linked list
Insertion of a node at the beginning of the list
Insertion of a node at the end of the list
Insertion of a node at a specified position of the list
3.1-Insertion of a node at the beginning of the list
3.2-Insertion of a node at the end of the list
3.3-Insertion of a node at a specified position
of the list
4. Delete an element in a circularly linked
list:
Deleting a node at the beginning of the list
Deleting a node at the end of the list
Deleting a node at a specified position of the list
4.1-Deleting a node at the beginning of the list
4.2-Deleting a node at the end of the list
4.3-Deleting a node at a specified position of the list
5. Search an element in the list:

You might also like