Bitonic Sort
Build bitonic sequences and merge them through a fixed comparison network whose columns can run in parallel.
Core idea
A bitonic network first creates sequences that rise and then fall, then merges them with compare-exchange stages whose distances repeatedly halve. The comparator pattern depends only on positions, not values.
Read the visualization
Read the network from left to right. Comparators in one column are independent and can execute together; each highlighted pair is oriented toward the order required by its current bitonic block.
Arrange the input at the left edge of the fixed comparison network.
Complexity and tradeoffs
Time: O(n log^2 n). Space: O(1) auxiliary. The data-independent network suits parallel hardware and normally expects a power-of-two length.
Where it fits
Data-independent comparisons make Bitonic Sort useful on sorting networks, SIMD hardware, and GPUs. Padding or a specialized network is needed when the input length is not a power of two.