Lably
Skip to content

Bitonic sorter

  • 7 min read
  • 3 chapters

Explore on Lably

ToursExplore Lably’s 3D tours

A sorted sequence is a monotonically non-decreasing (or non-increasing) sequence. A bitonic sequence is a sequence with x0≤⋯≤xk≥⋯≥xn−1 for some k,0≤k<n, or a circular shift of such a sequence.

Complexity

Let p=⌊log2⁡n⌋ and q=⌈log2⁡n⌉.

It is evident from the construction algorithm that the number of rounds of parallel comparisons is given by q(q+1)/2.

It follows that the number of comparators c is bounded 2p−1⋅p(p+1)/2≤c≤⌊n/2⌋⋅q(q+1)/2 (which establishes an exact value for c when n is a power of 2).

Although the absolute number of comparisons is typically higher than Batcher's odd-even sort, many of the consecutive operations in a bitonic sort retain a locality of reference, making implementations more cache-friendly and typically more efficient in practice.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication