1 / 10

Bitonic and Merging sorting networks

Bitonic and Merging sorting networks. Lecture 16 Efficient Parallel Algorithms COMP308. Bitonic sequence. Bitonic sequence is a sequence that either monotonically increases and the then monotonically decreases, or else monotonically decreases and then monotonically increases.

kaycee
Download Presentation

Bitonic and Merging sorting networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bitonic and Merging sorting networks Lecture 16 Efficient Parallel Algorithms COMP308

  2. Bitonic sequence • Bitonic sequence is a sequence that • either monotonically increases and the then monotonically decreases, • or else monotonically decreases and then monotonically increases. • For example • <1,4,6,8,3,2> • <9,8,3,2,4,6> are both bitonic • 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.

  3. The half-cleaner • The bitonic sorter is comprised of several stages, each of which is called a half-cleaner. • Each half-cleaner is a comparison network of depth 1 in which input line i is compared with linei + n/2for i = 1,2,…,n/2. • When a bitonic sequence of 0’s and 1’s is applied as input to a half-cleaner, the half-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.

  4. The comparison network Half-cleaner 0 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 0 bitonic clean bitonic bitonic bitonic bitonic clean bitonic

  5. 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-cleaners. • 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.

  6. Proof:

  7. The bitonic sorter • By recursively combining half-cleaners we can build a bitonic sorter, which is a network that sorts bitonic sequences. • The first stage of bitonic-sorter[n] is half-cleaner[n] , which produces two bitonic sequences. • Thus we can complete the sort by using two copies of bitonic-sorter[n/2]

  8. A Merging Network • Our sorting network will be constructed from merging networks, which are networks that can merge two sorted sequences into one sorted output sequence. • We modify the first half cleaner in the Bitonic-sorter[n]

  9. A network that merges two sorted input sequences into one sorted output sequence Merger Bitonic sorter Bitonic sorter

  10. Merger Sorter [n/2] Sorter [n/2] Sorting network 1 2 2 3 4 4 4 4 5 5 6

More Related