Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.

Slides:



Advertisements
Similar presentations
Sorting in Linear Time Introduction to Algorithms Sorting in Linear Time CSE 680 Prof. Roger Crawfis.
Advertisements

II Extreme Models Study the two extremes of parallel computation models: Abstract SM (PRAM); ignores implementation issues Concrete circuit model; incorporates.
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
Analysis of Algorithms CS 477/677 Linear Sorting Instructor: George Bebis ( Chapter 8 )
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Lower bound for sorting, radix sort COMP171 Fall 2005.
Advanced Topics in Algorithms and Data Structures Lecture 6.1 – pg 1 An overview of lecture 6 A parallel search algorithm A parallel merging algorithm.
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
Lecture 5: Linear Time Sorting Shang-Hua Teng. Sorting Input: Array A[1...n], of elements in arbitrary order; array size n Output: Array A[1...n] of the.
CS 253: Algorithms Chapter 8 Sorting in Linear Time Credit: Dr. George Bebis.
CIS 101: Computer Programming and Problem Solving Lecture 6 Usman Roshan Department of Computer Science NJIT.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
2 -1 Analysis of algorithms Best case: easiest Worst case Average case: hardest.
Lecture 5: Master Theorem and Linear Time Sorting
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
Sorting networks Efficient Parallel Algorithms COMP308.
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
Sorting Lower Bound Andreas Klappenecker based on slides by Prof. Welch 1.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
The Design and Analysis of Algorithms
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
1.7 Arrays academy.zariba.com 1. Lecture Content 1.Basic Operations with Arrays 2.Console Input & Output of Arrays 3.Iterating Over Arrays 4.List 5.Cloning.
Fundamental Structures of Computer Science March 02, 2006 Ananda Guna Binomial Heaps.
Computer Algorithms Lecture 11 Sorting in Linear Time Ch. 8
Data Structure & Algorithm Lecture 7 – Linear Sort JJCAO Most materials are stolen from Prof. Yoram Moses’s course.
Sorting in Linear Time Lower bound for comparison-based sorting
CSE 373 Data Structures Lecture 15
Linear Sorts Chapter 12.3, Last Updated: :39 AM CSE 2011 Prof. J. Elder Linear Sorts?
Jessie Zhao Course page: 1.
David Luebke 1 10/13/2015 CS 332: Algorithms Linear-Time Sorting Algorithms.
Parallel and Distributed Algorithms Eric Vidal Reference: R. Johnsonbaugh and M. Schaefer, Algorithms (International Edition) Pearson Education.
Searching. The process used to find the location of a target among a list of objects Searching an array finds the index of first element in an array containing.
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
Lecture 3 Induction & Sort(1) Algorithm design techniques: induction Selection sort, Insertion sort, Shell sort...
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Section 3.1. Section Summary Properties of Algorithms Algorithms for Searching and Sorting Greedy Algorithms Halting Problem.
Searching and Sorting Recursion, Merge-sort, Divide & Conquer, Bucket sort, Radix sort Lecture 5.
Cpt S 223 – Advanced Data Structures Math Review 2
Lecture 4 Sorting Networks. Comparator comparator.
1 Danny Hillis and Co-evolution Between Hosts and Parasites I 590 4/11/2005 Pu-Wen(Bruce) Chang.
ALGORITHMS.
1 Algorithms CSCI 235, Fall 2015 Lecture 17 Linear Sorting.
1 Sorting Networks Sorting.
Lecture 6COMPSCI.220.FS.T Data Sorting Ordering relation: places each pair ,  of countable items in a fixed order denoted as (  ) or 
Lecture 5 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
CSE15 Discrete Mathematics 03/06/17
Lecture 4 Sorting Networks
Sorting Networks Characteristics The basic unit: a comparator
7.1 What is a Sorting Network?
SORTING NETWORKS.
Introduction to Algorithms
Lecture 5 Algorithm Analysis
Lecture 5 Algorithm Analysis
كلية المجتمع الخرج البرمجة - المستوى الثاني
Comparison Networks Sorting Sorting binary values
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Lecture 6 Algorithm Analysis
Linear-Time Sorting Algorithms
Lecture 5 Algorithm Analysis
Time Complexity Lecture 15 Mon, Feb 27, 2006.
Algorithms CSCI 235, Spring 2019 Lecture 18 Linear Sorting
Efficient Parallel Algorithms COMP308
Lecture 5 Algorithm Analysis
Presentation transcript:

Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions

Sorting Algorithms comparisons to sort n elements comparisons required to merge two arrays of size m/2 Order of comparisons not fixed in advance. Mergesort(array[1,…,n] of Integers): begin Mergesort(array[1,…,n/2]); Mergesort(array[n/2+1,…,n]); Merge(array[1,…,n/2], array[n/2+1,…,n]); end Not readily implementable in hardware. Example

Sorting Networks Order of comparisons fixed in advance. Readily implementable in hardware. C D B A A B C D Sorting Network

Sorting Networks (binary values) Sorting Network inputs outputs sorted

Comparator (2-sorter) x y min(x, y) max(x, y) inputs outputs C

Comparator (2-sorter) x y min(x, y) max(x, y) inputs outputs

Comparison Network depth d width n

Comparison Network n / 2 comparisons per stage d stages

Sorting Network Any ideas?

Sorting Network inputs outputs n 1 Sorting Network n...

Insertion Sort Network inputs outputs depth 2n 3

Batcher Sorting Network Next Lecture

Sorting Arbitrary Numbers x, y can be values from any linearly ordered set, e.g., integers, reals, etc. inputs outputs x y min(x, y) max(x, y)

Comparison function: C(X,Y) = 1 if X > Y, 0 otherwise. Idea: use C(X,Y) to select the min and the max of X and Y. X, Y: integers represented as m-bit binary strings. Integer Comparator

Sorting Arbitrary Numbers sorted 6 9 2

Sorting Arbitrary Numbers sorted 4 5 1

Sorting Arbitrary Numbers not sorted How can we verify if a network sorts all possible input sequences?

Sorting Arbitrary Numbers inputsoutputs Try all possible 0/1 sequences.

Sorting Arbitrary Numbers inputsoutputs Try all possible 0/1 sequences.

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences. 001

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences not sorted!

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences not sorted!

Sorting Arbitrary Numbers

inputsoutputs Try all possible 0/1 sequences.

Sorting Arbitrary Numbers inputsoutputs Try all possible 0/1 sequences.

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences. 001

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences

Sorting Arbitrary Numbers inputsoutputs 000 Try all possible 0/1 sequences all sorted!

Zero-One Principle If a comparison network sorts all possible sequences of 0’s and 1’s correctly, then it sorts all sequences of arbitrary numbers correctly.

Lemma Given For a monotonically increasing function f,

Lemma Given For a monotonically increasing function f,

Proof: Lemma

f is monotonically increasing:

Proof: Lemma f is monotonically increasing:

Proof: Lemma f is monotonically increasing:

Generalization Given

For a monotonically increasing function f, Generalization (by induction)

Proof: Zero-One Principle Suppose b) there exists a sequence that it doesn’t sort, i.e., such that but is placed before in the output. a) the network sorts all sequences of 0’s and 1’s, Define f (x) = 0 if 1 otherwise

Proof: Zero-One Principle Sorting Network

Proof: Zero-One Principle Sorting Network

Proof: Zero-One Principle Sorting Network contradiction!