VOOZH about

URL: https://www.geeksforgeeks.org/dsa/split-a-circular-linked-list-into-two-halves/

⇱ Split a Circular Linked List into two halves - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Split a Circular Linked List into two halves

Last Updated : 27 Feb, 2026

Given a Circular linked list. The task is split into two Circular Linked lists. If there are an odd number of nodes in the given circular linked list then out of the resulting two halved lists, the first list should have one node more than the second list.

Examples:

Input: 10->4->9
Output: 10->4 , 9
Explanation: Number of nodes in circular Linked List are odd, so it will split as shown below.

👁 Image


Input: head: 10->4->9->7
Output: 10->4 , 9->7
Explanation: Number of nodes in circular Linked List are even, so it will split from two equal halves.

[Approach] Split Circular Linked List – O(n) Time and O(1) Space

The idea is to find the middle and last nodes using Hare and Tortoise Algorithm. Traverse linked list using a slow pointer and a fast pointer. Move the slow pointer to the next node(one node forward) and the fast pointer to the next of the next node(two nodes forward). When the fast pointer reaches the last node or second last node, then the slow pointer will reach the middle of the linked list. We can now easily split circular linked list and then point the tail nodes to their respective head nodes.

Step-by-step approach:

  • Traverse the circular linked list using the fast and slow pointer technique to find the middle and last nodes. The slow pointer will reach the middle, and the fast pointer will reach the end.
  • If the list has an odd number of nodes, the fast pointer will reach the last node. If the list has an even number, it will stop just before the last node.
  • Once the middle node is found, split the list into two halves. The first half starts from the head, and the second half starts from the node after the middle node.
  • Update the next pointers of the middle and last nodes to make each half circular by pointing them to their respective head nodes.
  • Function returns two circular linked lists representing the split halves.

Output
1 2 
3 4 
Comment
Article Tags: