Download presentation

Presentation is loading. Please wait.

Published byDevante Mountford Modified about 1 year ago

1
Batcher’s merging network Efficient Parallel Algorithms COMP308

2
Odd-even merging network We assume that n is exact power of 2, and we wish to merge the sorted sequence of elements on lines with those on lines We recursively construct two odd-even merging networks that merge sorted subsequences in parallel.

3
Structure of the network The first merges the sequence on lines with sequences on lines (the odd elements) The second merges the sequence on lines with sequences on lines (the even elements) To combine two sorted subsequences, we put a comparator between a 2i-1 and a 2i for all i=1,2,…,n

4

5

6

7
8-input network

8
Skeleton of the Proof Apply the zero-one principle to prove that Batcher’s sorting is correct, consider only merges of sequences of the form and In odd-even merging we send odd sequence to one merger and the even sequence to another merger. We can assume by induction that smaller mergers work correctly. The first merger can get one or two more zeros. than the second one. The outputs of these mergers are interleaved and can be 1 before 0 (dirty one).

9
After sorting separately on odd and even positions we will have everything sorted unless the situation like this happens Then the last final touch (correction step) cleans the sequence. The situation is subtle, the last correction does not clean for example But the dirty 1 (if there is any) should be on an even position, which is always the case

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google