A circular linked list has no NULL at the end: the last node points back to the first, so the nodes form a ring. This visualizer shows the ring in memory with real addresses and arrows, including the pointer from the tail back to the head. A switch turns it from a circular singly linked list into a circular doubly linked list, where the head’s prev pointer also points to the tail.
Insert at the head, tail or an index, delete, search and reverse, and see how each operation keeps the circle closed. Because the tail points to the head, keeping just a tail pointer gives O(1) access to both ends, a trick used by many real implementations.
How to use the Circular Linked List Visualizer tool
- Choose Singly or Doubly links.
- Type a value (and an index) and pick an operation.
- Watch the arrow from the last node back to the first, and the red arrow for the pointer being changed.
- Step back and forth, or switch to List order to see the ring as a row that wraps around.
Why use ToolOrca Circular Linked List Visualizer
- Circular singly and circular doubly modes
- Tail-to-head link drawn in memory
- Insert at head, tail or index, delete, search, reverse
- Search stops after one full lap
- Pseudocode for each mode, with the active line highlighted
- Code in C++, Java, Python and JavaScript
How a circular linked list works
In a circular singly linked list the last node’s next pointer holds the address of the first node. If you keep a pointer to the tail, the head is just tail.next, so both ends are one step away: inserting at the head or the tail is O(1). In a circular doubly linked list the head’s prev pointer also points to the tail.
Since there is no NULL, loops must stop in a different way: you stop when you get back to the node you started from. Forgetting this is the classic bug with circular lists, an endless loop.
Keeping the circle closed
Every operation must keep the ring intact. Inserting at the head means node.next = head, then tail.next = node. Inserting at the tail is the same plus moving tail to the new node. Deleting the only node empties the list; deleting the head or tail means updating the pointer that referred to it. A single node points to itself.
Where circular lists are used
Circular lists suit anything that cycles: round-robin CPU scheduling, taking turns in multiplayer games, the Josephus problem, repeating playlists and ring buffers. Search, access by index and deleting by value are still O(n), as in any linked list.
Every visualizer on this site runs in your browser with the same controls: Play, Pause, Step forward, Step back and a speed slider. You can also drag the position slider to jump to any step, or focus the drawing and use the Space bar and arrow keys.
Frequently asked questions
What is a circular linked list?
A linked list where the last node points back to the first instead of to NULL, so you can keep walking around the list forever.
How do you know when you have visited every node?
Remember the node you started from (usually the head) and stop when the next pointer brings you back to it.
Why keep a tail pointer instead of a head pointer?
Because tail.next is the head, a single tail pointer gives O(1) access to both ends. With only a head pointer, reaching the tail would take O(n).
What is the Josephus problem?
People stand in a circle and every k-th person is removed until one remains. A circular linked list models it directly: walk k steps, delete a node, repeat.