Middle of Linked List Visualization & Animation

Finds the middle node of a linked list in one pass using fast (×2) and slow (×1) pointers.

## What is it? Find the middle node of a singly linked list in a single pass using the fast and slow pointer (Floyd's tortoise and hare) technique. ## How it works - Use two pointers: `slow` and `fast`, both starting at `head` - Move `slow` one step and `fast` two steps each iteration - When `fast` reaches the end (or `fast.next == null`) → `slow` is at the middle - For even-length lists, this returns the second middle node ## When to use - Splitting a linked list into two halves (e.g., for Merge Sort on linked lists) - Palindrome Linked List check (find middle, reverse second half, compare) - Any problem requiring the midpoint of a linked list ## Key Points - O(n) time, O(1) space — no need to count length first - The fast-slow pointer trick is reused in cycle detection, kth-from-end, and more - Handles both odd-length (one clear middle) and even-length (convention: second middle)

Category: algorithms

Difficulty: beginner

Time Complexity: O(n)

Space Complexity: O(1)

Middle of Linked List

beginner

Finds the middle node of a linked list in one pass using fast (×2) and slow (×1) pointers.

Initializing
Comparisons: 0
null12345slowfast
We place both pointers at the head — node 1. Slow will advance one step at a time, while fast will advance two steps at a time.