430 likes | 464 Views
Lecture 4 Sorting Networks. Comparator. comparator. A Sorting Network. 2. 2. 9. 5. 6. 5. 9. 5. 2. 5. 6. 2. 6. 9. 6. 9. A sorting network is a comparison network which output monotone nondecreasing sequence for every input. Depth. 2. 2. 9. 5. 6. 5. 9. 5. 2. 5. 6.
E N D
Comparator comparator
A Sorting Network 2 2 9 5 6 5 9 5 2 5 6 2 6 9 6 9 A sorting network is a comparison network which output monotone nondecreasing sequence for every input.
Depth 2 2 9 5 6 5 9 5 2 5 6 2 6 9 6 9 Depth is the maximum number of comparators on a pathfrom an input wire to an output wire.
Depth = parallel time 2 2 9 5 6 5 9 5 2 5 6 2 6 9 6 9 Depth is the maximum number of comparators on a pathfrom an input wire to an output wire.
Divide and Conquer • Divide the problem into subproblems. • Conquer the subproblems by solving them recursively. • Combine the solutions to subproblems into the solution for original problem.
Structure Sorting network Merging network Sorting network
Construction of Merging Network • 0-1 principal. • Bitonic sorter. • Merging network.
The half-cleaner 0 0 0 0 bitonic clean 1 0 1 0 bitonic 1 1 0 0 bitonic 1 0 0 1
The half-cleaner 0 0 0 0 bitonic 1 1 1 0 bitonic 1 1 1 1 bitonic clean 1 1 0 1
Lemma One of two halfs is bitonic clean. every number in the 1st half ≤ any element in the 2nd half.
Proof (case 1) 0 0 1 0 1 1 0 0 0
Proof (case 2) 0 0 1 0 1 0 0 1 0
Proof (case 3) 0 0 1 0 1 1 1 0 0 0 1
Proof (case 4) 0 0 1 1 1 0 0 1 1 0 0
Proof (case 5) 1 1 0 0 1 1 1 1 0 1 1
Proof (case 6) 1 1 0 1 1 1 0 1 1 0 1
Proof (case 7) 1 0 1 1 0 0 1 1 0 0 1
Proof (case 8) 1 0 1 0 1 0 1 0 0 1 1
bitonic sorted Half cleaners
0 0 0 0 sorted 0 0 1 0 sorted 0 0 0 1 sorted 1 1 1 1 Half cleaners Merging Network
Structure Sorting network Merging network Sorting network
Sorting Network Merging Networks
What we learnt in this lecture? • What is sorting network? • Depth = parallel time. • Sorting network from Merge sort.
Permutation Network • Switching network • Rearrangeability • Nework with 2x2 crossbars
Crossbar Switch A crossbar switch can realize any matching between Inputs and outputs.
3-stage Clos Network 1 n n n n m
Rearrangeability Theorem