10 Sorting
10 Sorting
Computation
PARALLEL SORTING
Bitonic Merge and Sort
• Bitonic sequence: {a0, a1, …, an-1}:
– A sequence with a monotonically increasing part
and a monotonically decreasing part
• For some i, {a0<= …<=ai} and {ai+1>= …>= an-1}
– Or, a cyclic-shift of indices makes it bitonic
Two Bitonic Sequences
Subsequence 2
Subsequence 1
3 7 6 6 4 1 2
8 8 8 7 2 3 3
6 6 7 8 1 4 4 log n stages
log2n time
4 1 5 5 5 5 5
n log2n work
1 4 4 4 6 6 6
5 5 1 2 7 7 7
2 2 2 1 8 8 8
P0 P1 Pp-1