Odd-even sort, or odd-even transposition sort, alternates two adjacent compare-swap phases. The odd phase compares (1,2), (3,4), …; the even phase compares (0,1), (2,3), …. Pairs within one phase are disjoint, so they can run in parallel without writing the same element.

A complete odd/even phase pair covers every adjacent boundary. If neither phase swaps, no adjacent inversion exists and the array is sorted. The algorithm matters mainly as a simple sorting network for parallel processors.

Visualization

The trace alternates odd-start and even-start pairs. Values move at most one position per phase, so a value far from its destination needs multiple phases even though comparisons inside a phase are independent.

Complexity
n
number of elements in the array

With enough processors, one phase performs about n/2 comparisons concurrently and sorting takes O(n) parallel phases, while total work remains O(n²). The plotted table describes sequential execution.

Boundary and implementation

Strict > comparison makes the sequential form stable because equal adjacent values never cross. A real parallel implementation needs a barrier between phases so the next set does not start while the previous set still owns array positions.

Questions

References