Sorting Networks Uri Zwick Tel Aviv University May 2015.

Slides:



Advertisements
Similar presentations
II Extreme Models Study the two extremes of parallel computation models: Abstract SM (PRAM); ignores implementation issues Concrete circuit model; incorporates.
Advertisements

Primitive Recursive Functions (Chapter 3)
Longest Common Subsequence
1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
Exercise 1.1(Paid Exchanges Necessary) Consider the three-element list with the following initial configuration: (i.e. x1 is at the front). Prove that.
Lower bound: Decision tree and adversary argument
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
CSE115/ENGR160 Discrete Mathematics 02/28/12
Parallel Sorting Algorithms Comparison Sorts if (A>B) { temp=A; A=B; B=temp; } Potential Speed-up –Optimal Comparison Sort: O(N lg N) –Optimal Parallel.
1 Omega Network The omega network is another example of a banyan multistage interconnection network that can be used as a switch fabric The omega differs.
1 Delta Network The delta network is one example of a multistage interconnection network that can be used as a switch fabric The delta network is an example.
1 Tuesday, November 14, 2006 “UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Design of parallel algorithms Sorting J. Porras. Problem Rearrange numbers (x 1,...,x n ) into ascending order ? What is your intuitive approach –Take.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
1 Module 31 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union, concatenation.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
Sorting networks Efficient Parallel Algorithms COMP308.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
CSCI-455/552 Introduction to High Performance Computing Lecture 22.
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
1 Strong Mathematical Induction. Principle of Strong Mathematical Induction Let P(n) be a predicate defined for integers n; a and b be fixed integers.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
Computer Algorithms Lecture 11 Sorting in Linear Time Ch. 8
Why is it the second most important theorem in calculus?
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
Outline  introduction  Sorting Networks  Bubble Sort and its Variants 2.
Parallel and Distributed Algorithms Eric Vidal Reference: R. Johnsonbaugh and M. Schaefer, Algorithms (International Edition) Pearson Education.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Comparison Networks Sorting Sorting binary values
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
Lecture 4 Sorting Networks. Comparator comparator.
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
Data Structures Haim Kaplan & Uri Zwick December 2013 Sorting 1.
Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
SECTION 9 Orbits, Cycles, and the Alternating Groups Given a set A, a relation in A is defined by : For a, b  A, let a  b if and only if b =  n (a)
Counting and Distributed Coordination BASED ON CHAPTER 12 IN «THE ART OF MULTIPROCESSOR PROGRAMMING» LECTURE BY: SAMUEL AMAR.
1 Sorting Networks Sorting.
+ Even Odd Sort & Even-Odd Merge Sort Wolfie Herwald Pengfei Wang Rachel Celestine.
 2004 SDU 1 Lecture5-Strongly Connected Components.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes P i and P j send their elements to each other. Process P.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Lower Bounds & Sorting in Linear Time
Lecture 4 Sorting Networks
Sorting Networks Characteristics The basic unit: a comparator
7.1 What is a Sorting Network?
Unit 1. Sorting and Divide and Conquer
SORTING NETWORKS.
The first Few Slides stolen from Boaz Barak
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
Comparison Networks Sorting Sorting binary values
Analysis of Algorithms
Parallel Sorting Algorithms
Bitonic and Merging sorting networks
Delta Network The delta network is one example of a multistage interconnection network that can be used as a switch fabric The delta network is an example.
Lecture 6 Algorithm Analysis
Data Structures Sorting Haim Kaplan & Uri Zwick December 2014.
Lower Bounds & Sorting in Linear Time
Lecture 6 Algorithm Analysis
Equivalence We have already introduced the idea of equivalence
Batcher Sorting Network, n = 4
Efficient Parallel Algorithms COMP308
Presentation transcript:

Sorting Networks Uri Zwick Tel Aviv University May 2015

Comparators Can we use comparators to build efficient sorting networks?

Comparator networks A comparator network is a network composed of comparators. Each output of a comparator is either an output wire, or feeds a single comparator. The network must be acyclic.

“Standard form” Exercise: Show that any comparator network is equivalent to a network in standard form.

A simple sorting network 5 comparators 3 levels

Insertion sort

Selection/bubble sort

Selection/bubble Sort

Odd-Even Transposition Sort

The 0-1 principle Theorem: If a network sort all 0-1 inputs, then it sort all inputs

The 0-1 principle

Suppose that a network is not a sorting network. Proof: Thus, the network does not sort all 0-1 inputs.

Sorting by merging

Batcher’s odd-even merge

Does it really work?

Batcher’s odd-even merge

The difference is either 0,1 or 2! Proof using the 0-1 principle. There is a problem only if difference is 2 and last level of comparators fixes it.

Batcher’s odd-even merge

Batcher’s odd-even merge Exercise: Justify the use of the 0-1 principle. Exercise: Prove the correctness of the odd-even merging network directly without relying on the 0-1 principle.

Batcher’s odd-even merge Size – number of comparators Are the odd-even merge networks optimal?

Bitonic sequences A sequence is bitonic iff it is a cyclic shift of a strict bitonic sequence A sequence is strict bitonic iff it is a concatenation of a decreasing sequence and an increasing sequence

A Bitonic sorter A (strict) bitonic sorter is a network that sorts every (strict) bitonic sequence. Thus, a strict bitonic sorter can serve as a merging network

Batcher’s bitonic sorter Is this different from odd-even merge?

The odd and even subsequences are also strict binary bitonic sequences. Simple proof using the 0-1 principle. Batcher’s bitonic sorter By induction they are sorted correctly. Final level of comparators fixes the problem.

Batcher’s bitonic sorter

Very regular structure!

Sorts general bitonic sequences

The AKS sorting networks [Ajtai-Komlós-Szemerédi (1983)] The construction is fairly complicated. The constant factors are very large.