Sorting networks Efficient Parallel Algorithms COMP308.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

1 Parallel Algorithms (chap. 30, 1 st edition) Parallel: perform more than one operation at a time. PRAM model: Parallel Random Access Model. p0p0 p1p1.
Mathematical Induction
PERMUTATION CIRCUITS Presented by Wooyoung Kim, 1/28/2009 CSc 8530 Parallel Algorithms, Spring 2009 Dr. Sushil K. Prasad.
Functional Verification III Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 23.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Batcher’s merging network Efficient Parallel Algorithms COMP308.
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
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.
1 Chapter 22: Elementary Graph Algorithms IV. 2 About this lecture Review of Strongly Connected Components (SCC) in a directed graph Finding all SCC (i.e.,
Outline. Theorem For the two processor network, Bit C(Leader) = Bit C(MaxF) = 2[log 2 ((M + 2)/3.5)] and Bit C t (Leader) = Bit C t (MaxF) = 2[log 2 ((M.
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
Discrete Structures & Algorithms Functions & Asymptotic Complexity.
The main idea of the article is to prove that there exist a tester of monotonicity with query and time complexity.
1 Huffman Codes. 2 Introduction Huffman codes are a very effective technique for compressing data; savings of 20% to 90% are typical, depending on the.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
So far we have learned about:
Data Flow Analysis Compiler Design Nov. 8, 2005.
Mesh connected networks. Sorting algorithms 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.
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
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.
MIT Foundations of Dataflow Analysis Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Reading and Writing Mathematical Proofs
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!
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
C&O 355 Mathematical Programming Fall 2010 Lecture 4 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A.
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.
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
Genome Rearrangements Unoriented Blocks. Quick Review Looking at evolutionary change through reversals Find the shortest possible series of reversals.
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
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Universidad Nacional de ColombiaUniversidad Nacional de Colombia Facultad de IngenieríaFacultad de Ingeniería Departamento de Sistemas- 2002Departamento.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
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.
Chapter 8 Maximum Flows: Additional Topics All-Pairs Minimum Value Cut Problem  Given an undirected network G, find minimum value cut for all.
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.
Fault tolerance and related issues in distributed computing Shmuel Zaks GSSI - Feb
1 Sorting Networks Sorting.
Chapter Three SEQUENCES
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Sorting by placement and Shift Sergi Elizalde Peter Winkler By 資工四 B 周于荃.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
Chapter 1 Logic and Proof.
Lecture 4 Sorting Networks
Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2012
Mesh connected networks. Sorting algorithms
Sorting Networks Characteristics The basic unit: a comparator
SORTING NETWORKS.
Asymptotic Notations Algorithms Lecture 9.
Enumerating Distances Using Spanners of Bounded Degree
Advanced Algorithms Analysis and Design
Comparison Networks Sorting Sorting binary values
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Lecture 6 Algorithm Analysis
Chapter 11: Further Topics in Algebra
Mathematical Induction
Efficient Parallel Algorithms COMP308
Presentation transcript:

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) COMPARATOR x y x’ y’

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 and the output sequence, 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 b 1  b 2  …  b n ) 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 = into the output sequence b =, then for any monotonically increasing function f, the network transforms the input sequence f(a) = into sequence f(b) =.

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))

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 a i when the input sequence a is applied to the network, then it assumes the value f(a i ) when the input sequence f(a) is applied. f(x) f(y) min(f(x), f(y))=f(min(x,y)) max(f(x), f(y))=f(max(x,y))

Example 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 2 n 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 = containing elements a i and a j such that a i < a j,but network place a j before a i in the output sequence.

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