0% found this document useful (0 votes)
3 views

Lecture18

Uploaded by

sachdevagngn13
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture18

Uploaded by

sachdevagngn13
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Bitonic sequence

Bitonic and Merging sorting n Bitonic sequence is a sequence that


– either monotonically increases and the
networks then monotonically decreases,
– or else monotonically decreases and then
monotonically increases.
n For example
– <1,4,6,8,3,2>
Efficient Parallel Algorithms – <9,8,3,2,4,6> are both bitonic
COMP308 n The zero-one sequences that are
bitonic have a simple structure. They
have the form 0i1j0k or the form 1i0j1k,
for some i,k,j≥0.

The comparison network Half-


The half-cleaner
cleaner
n The bitonic sorter is comprised of several
0 0 0 0
stages, each of which is called a half-
0 0 0 0

bitonic
bitonic
cleaner.
clean
1 0 1 1
n Each half-cleaner is a comparison network of 0 0
bitonic

bitonic
1 1
depth 1 in which input line i is compared with 1 1 1 1
bitonic

line i + n/2 for i = 1,2,…,n/2.

bitonic
0 0 1 1

clean
n When a bitonic sequence of 0’s and 1’s is 0 1 1 1
applied as input to a half-cleaner, the half- 0 1 0 1
cleaner produces an output sequence in
which smaller values are in the top half,
larger values are in the bottom half, and both
halves are bitonic.

In fact at least one of the halves is clean – consisting all 0’s or


all 1’s. The next lemma proves these properties of half- Proof:
cleaners.

n Lemma. If the input to a halve-cleaner is a


bitonic sequence of 0’s and 1’s, then the output
satisfies the following properties:
– both the top and the bottom half are bitonic,
– every element in the top half is at least as small as
every element of the bottom half, and
– at least one half is clear.

1
The bitonic sorter
n By recursively combining half-cleaners we A Merging Network
can build a bitonic sorter, which is a network
that sorts bitonic sequences.
n The first stage of bitonic-sorter[n] is half- n Our sorting network will be constructed
cleaner[n] , which produces two bitonic from merging networks, which are
sequences. networks that can merge two sorted
n Thus we can complete the sort by using two sequences into one sorted output
copies of bitonic-sorter[n/2]
sequence.
n We modify the first half cleaner in the
Bitonic-sorter[n]

A network that merges two sorted input


sequences into one sorted output sequence Sorting network
Sorter [n/2]
Merger
Merger Sorter [n/2]
Bitonic
sorter

Bitonic
sorter

1 22 3 4444 55 6

You might also like