#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Linked Lists

Circular Linked List in Data Structure

A Circular Linked List is a variation of a linked list in which the last node points back to the first node instead of pointing to None, forming a circular chain.

Types

  • Singly Circular Linked List: each node points to the next, and the last node points back to the head.
  • Doubly Circular Linked List: each node has both next and previous pointers, and the list forms a loop in both directions.
class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

class CircularLinkedList:
    def __init__(self):
        self.head = None

    def append(self, data):
        new_node = Node(data)
        if not self.head:
            self.head = new_node
            new_node.next = self.head
            return
        current = self.head
        while current.next != self.head:
            current = current.next
        current.next = new_node
        new_node.next = self.head

    def traverse(self):
        if not self.head:
            return []
        values = [self.head.data]
        current = self.head.next
        while current != self.head:
            values.append(current.data)
            current = current.next
        return values

Complexity

OperationTime
Insert at endO(n) without tail pointer, O(1) with tail pointer
TraversalO(n)

Applications

  • Round-robin CPU scheduling.
  • Implementing circular buffers for streaming data.
  • Multiplayer turn-based games cycling through players.
  • Managing playlists that loop back to the first song.

Ready to master Data Structures & Algorithms?

Learn DSA hands-on with mentor-led sessions, real interview practice, and placement support.

Explore Course