Lecture 4 Sorting Networks
Comparator comparator
A Sorting Network A sorting network is a comparison network which output monotone nondecreasing sequence for every input.
Depth Depth is the maximum number of comparators on a path from an input wire to an output wire.
Depth = parallel time Depth is the maximum number of comparators on a path from an input wire to an output wire.
Insertion Sort
key
Sorting network constructed from insertion sort.
How to construct a sorting network from merging sort?
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.
Merge Sort
Procedure
Structure Sorting network Sorting network Merging network
Construction of Merging Network 0-1 principal. Bitonic sorter. Merging network.
0-1 principal
Lemma
Proof of 0-1 Principal
Bitonic Sequence
Bitonic 0-1 Sequence
Some Properties
The half-cleaner bitonic clean bitonic
The half-cleaner bitonic clean bitonic
Lemma (a)One of two halfs is bitonic clean. (b) every number in the 1 st half ≤ any element in the 2 nd half.
Proof (case 1)
Proof (case 2)
Proof (case 3)
Proof (case 4)
Proof (case 5)
Proof (case 6)
Proof (case 7)
Proof (case 8)
Half cleaners bitonicsorted
Half cleaners sorted Merging Network
Structure Sorting network Sorting network Merging network
Merging Networks Sorting Network
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 m n n n n
Rearrangeability Theorem
Network with 2x2 crossbars
Puzzle