Efficient Parallel Algorithms COMP308

Slides:



Advertisements
Similar presentations
WSPD Applications.
Advertisements

Lower bound: Decision tree and adversary argument
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Complexity class NP Is the class of languages that can be verified by a polynomial-time algorithm. L = { x in {0,1}* | there exists a certificate y with.
The main idea of the article is to prove that there exist a tester of monotonicity with query and time complexity.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
Data Flow Analysis Compiler Design Nov. 8, 2005.
Sorting networks Efficient Parallel Algorithms COMP308.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
Index FAQ Limits of Sequences of Real Numbers 2013 Sequences of Real Numbers Limits through Definitions The Squeeze Theorem Using the Squeeze Theorem Monotonous.
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
Induction and recursion
Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs Presented by R 李孟哲 R 陳翰霖 R 張仕明 Sanjiv Kapoor and.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Design of Algorithms using Brute Force Approach. Primality Testing (given number is n binary digits)
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Comparison Networks Sorting Sorting binary values
Universidad Nacional de ColombiaUniversidad Nacional de Colombia Facultad de IngenieríaFacultad de Ingeniería Departamento de Sistemas- 2002Departamento.
Lecture 4 Sorting Networks. Comparator comparator.
X y x-y · 4 -y-2x · 5 -3x+y · 6 x+y · 3 Given x, for what values of y is (x,y) feasible? Need: y · 3x+6, y · -x+3, y ¸ -2x-5, and y ¸ x-4 Consider the.
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
Spanning tree Lecture 4.
Huffman Codes. Overview  Huffman codes: compressing data (savings of 20% to 90%)  Huffman’s greedy algorithm uses a table of the frequencies of occurrence.
1 Sorting Networks Sorting.
Main Menu Main Menu (Click on the topics below) Pigeonhole Principle Example Generalized Pigeonhole Principle Example Proof of Pigeonhole Principle Click.
Approximation Algorithms based on linear programming.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Sequences of numbers appear in diverse situations. If you divide a cake in half, and then divide the remaining half in half, and continue dividing in.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
Chapter 1 Logic and Proof.
Equivalence Relations
The Theory of NP-Completeness
Lecture 4 Sorting Networks
Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2012
New Characterizations in Turnstile Streams with Applications
Mesh connected networks. Sorting algorithms
Sorting Networks Characteristics The basic unit: a comparator
7.1 What is a Sorting Network?
Read Once Branching Programs: a model of computation used in CAD.
Advanced Algorithms Analysis and Design
Lecture12 The Halting Problem
SORTING NETWORKS.
CPSC 411 Design and Analysis of Algorithms
APPLICATIONS OF DIFFERENTIATION
Chapter 5 Induction and Recursion
CSCE 411 Design and Analysis of Algorithms
Lecture 7 Functions.
Lecture 22: Parallel Algorithms
Asymptotic Notations Algorithms Lecture 9.
CSCE 411 Design and Analysis of Algorithms
Rank Aggregation.
Advanced Algorithms Analysis and Design
The Curve Merger (Dvir & Widgerson, 2008)
Comparison Networks Sorting Sorting binary values
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Lecture 6 Algorithm Analysis
§2-2 Controllability of Linear Dynamical Equations
Advanced Analysis of Algorithms
APPLICATIONS OF DIFFERENTIATION
Chapter 11: Further Topics in Algebra
CPSC 411 Design and Analysis of Algorithms
Introduction To Algorithms
Mathematical Induction
Equivalence Relations
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Presentation transcript:

Efficient Parallel Algorithms COMP308 Sorting networks Efficient Parallel Algorithms COMP308

Sorting networks Today, we investigate sorting algorithms based on a comparison network model of computation in which many comparison operations can be performed simultaneously Sorting networks are comparison networks that always sort their inputs.They are comprised solely of wires and comparators

Comparator A comparator is a device with two inputs, x and y, and outputs, x’ and y’, that performs the following function: x’= min (x,y) y’= max (x,y) x x’ 7 3 COMPARATOR y y’ 3 7

Wire We shall assume that each comparator operates in O(1) time. In other words, we assume that the time between the appearance of the input values x and y and the production of the output values x’ and y’ is a constant. A wire transmits a value from place to place. Wires can connect the output of one comparator with the input of another, but otherwise they are either network input wires or network output wires.

We shall speak of the input sequence <a1,a2,…,an> and the output sequence <b1,b2,…,bn>, referring to the values on the input and output wires. A sorting network is a comparison network for which the output sequence is monotonically increasing (that is b1b2 …  bn) for every input sequence.

Example

The zero-one principle The zero-one principle says that if a sorting network works correctly when each input is drawn from the set {0,1}, then it works correctly on arbitrary input numbers. Once we constructed a sorting network and proved that it can sort all zero-one sequences, we shall appeal to the zero-one principle to show that it properly sorts sequences of arbitrary values.

The proof of the zero-one principle relies on the notion of a monotonically increasing function. Lemma If a comparison network transforms the input sequence a = <a1,a2,…,an> into the output sequence b = <b1,b2,…,bn>, then for any monotonically increasing function f, the network transforms the input sequence f(a) = <f(a1), f(a2),…, f(an)> into sequence f(b) = <f(b1), f(b2),…, f(bn)>.

Proof. We shall first prove the claim that if f is monotonically increasing function, then a single comparator with inputs f(x) and f(y) produces outputs f(min(x,y)) and f(max(x,y)). We shall then use induction to prove the lemma To prove the claim, consider a comparator whose input values are x and y. The upper output of the comparator is min(x,y) and the lower output is max(x,y). Suppose now apply f(x) and f(y) to the inputs of the comparator as is shown on the figure f(x) f(y) min(f(x), f(y))=f(min(x,y)) max(f(x), f(y))=f(max(x,y))

f(x) f(y) min(f(x), f(y))=f(min(x,y)) max(f(x), f(y))=f(max(x,y)) Since f is monotonically increasing xy imply f(x)f(y). Consequently, we ha the identities: min(f(x), f(y))=f(min(x,y)) max(f(x), f(y))=f(max(x,y)) We can use induction on the depth of each wire in a general comparison network to prove a stronger result than the statement of the lemma: If a wire assumes the value ai when the input sequence a is applied to the network, then it assumes the value f(ai) when the input sequence f(a) is applied.

Example 9 5 2 6 5 3 1 The sorting network with the monotonically increasing function f(x)=f(x/2) applied to the inputs.

Theorem. (0-1 principle) If comparison network with n inputs sorts all 2n possible sequences of 0’s and 1’s correctly, then it sorts all sequences of arbitrary numbers correctly. Proof. Suppose for the purpose of contradiction that the network sorts all zero-one sequences, but there exists a sequence of arbitrary numbers that the network does not correctly sort. That is, there exists an input sequence a = <a1,a2,…,an> containing elements ai and aj such that ai < aj,but network place aj before ai in the output sequence.

We define monotonically increasing function f as 0 if xai, f(x) = 1 if x>ai Since the network places aj before ai in the output sequence when <a1,a2,…,an> is input, it follows from Lemma that it place f(aj) before f(ai) in the output sequence when <f(a1),f(a2),…,f(an)> is input. But since f(aj)=1 and f(ai)=0, we obtain the contradiction that the network fails to sort the zero-one sequence <f(a1),f(a2),…,f(an)> correctly.