Circular Linked List
Circular Linked List
Algorithms
Module 2: Linear Data Structure- Circular Linked List
1
Introduction
A Circular Linked List is a type of linked list where:
• The last node returns to the first node, forming a circular
structure.
• There is no null reference in the last node, unlike a traditional
linked list.
• The list can be traversed continuously without encountering a
null pointer.
2
Graphical Representation
Head Data Link Data Link Data Link Data Link
Node 1 Node 1 Node 1 Node 1
Null
3
Key Characteristics
• Circular nature: In a circular linked list, the last node's next
pointer references the first node, creating a loop.
• No null pointers: Unlike a traditional linked list, no node in a
circular linked list contains a null pointer.
• Single traversal loop: You can traverse the entire list starting
from any node, and you will eventually return to the starting node.
4
Advantages
• Efficient traversal: Useful when you need to cycle through
elements repeatedly, such as in scheduling algorithms or in round-
robin fashion.
• No null checks: You don’t have to check for null at the end of the
list during traversal.
5
A ADT CircularLinkedList
Data:
Node
Data
Next
D
Operations:
CreateList() : Initialize an empty list
InsertAtBeginning(data) : Add data at the beginning
InsertAtEnd(data) : Add data at the end
InsertAfter(node, data) : Add data after a specific node
DeleteNode(data) : Remove node with the specified data
T
Search(data) : Return the node containing data
Display() : Display all nodes in the list
IsEmpty() : Return true if the list is empty
Size() : Return the number of nodes in the list
Traverse() : Traverse all nodes starting from any node
6
Insert at Beginning
7
Insert at End
8
Insert at Position
9
Delete at Beginning
10
Delete at End
11
Delete at Position
12
Display
13
Search
14
Application of Circular Linked
list:
15
Applications of Different
Types of Linked Lists:
• A linked list is used to implement stack and
queues.
• A linked list is used to represent sparse matrices.
• You can implement an image viewer using a
circular linked list.
• You can use the linked list concept to navigate
through web pages.
• You can use a circular doubly linked list to
implement a Fibonacci heap.
16