Odd-Even Sort Visualization
Odd-Even Sort alternates between comparing odd-indexed pairs and even-indexed pairs of neighbours.
How it works
Odd-Even Sort (also called brick sort) compares and swaps neighbours in two alternating phases: first pairs that start at odd positions, then pairs that start at even positions. It repeats until a full round makes no swaps.
On a single processor it is O(n²) like Bubble Sort. Its point is parallelism: within a phase no two comparisons touch the same element, so every comparison in a phase can run at the same time, one per processor. It is stable and in place.
What to watch for
Watch the whole picture shimmer as every pair is checked at once, with values drifting a step at a time.
Complexity
- Best
- n
- Average
- n²
- Worst
- n²
- Extra space
- 1
- Stable
- Yes
Race it
Same shuffle, same speed, one winner: Odd-Even vs Bubble. Or open the studio to try other layouts, sizes and speeds, and make a video of it.
FAQ
Why use Odd-Even Sort?
Each phase's comparisons are independent, so it maps well onto parallel hardware such as GPUs or sorting networks.
Is it stable?
Yes.