You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Circular Linked List is a linked data structure that consists of a set of sequentially linked records called nodes. Each node
is connected to the next node via a link field which refences the next node in sequence. Each node consists of a data/key.
In a circular linked list 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.
The head or starter pointer points to the beginning of the circular linked list.
1. Prepend - Add node to the beginning of the list
In a prepend operation - a node is added to the beginning of the circular linked list. The newly added node becomes the head of the Circular linked list.
Circular Linked List before Prepend operation
Circular Linked List after Prepend operation
2. Append - Add node to the end of the list
In an append operation - a node is added to the end of the circular linked list. This new node after insertion points to the beginning of the circular linked list or the head.
Circular Linked List before Append operation
Circular Linked List after Append operation
3. Insert After a Given Node or In between Nodes
If the circular linked list is empty - a node can be added via an append operation to create a new circular linked list with a single item.
Otherwise we traverse the list and the new node is added after the given node.
Circular Linked List before Insert - New node between nodes
Circular Linked List after Insert - New node between nodes