Lecture 4 Sorting Networks

Slides:



Advertisements
Similar presentations
Back to Sorting – More efficient sorting algorithms.
Advertisements

Batcher’s merging network Efficient Parallel Algorithms COMP308.
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
1 Divide & Conquer Algorithms. 2 Recursion Review A function that calls itself either directly or indirectly through another function Recursive solutions.
1 Merge Sort Review of Sorting Merge Sort. 2 Sorting Algorithms Selection Sort uses a priority queue P implemented with an unsorted sequence: –Phase 1:
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
Divide and Conquer Chapter 6. Divide and Conquer Paradigm Divide the problem into sub-problems of smaller sizes Conquer by recursively doing the same.
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.
Lecture 3 Nearest Neighbor Algorithms Shang-Hua Teng.
Text Chapters 1, 2. Sorting ä Sorting Problem: ä Input: A sequence of n numbers ä Output: A permutation (reordering) of the input sequence such that:
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
Lecture 2: Divide and Conquer I: Merge-Sort and Master Theorem Shang-Hua Teng.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
ALGORITHM ANALYSIS AND DESIGN INTRODUCTION TO ALGORITHMS CS 413 Divide and Conquer Algortihms: Binary search, merge sort.
Lecture 5 Dynamic Programming. Dynamic Programming Self-reducibility.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Lecture 2 Sorting. Sorting Problem Insertion Sort, Merge Sort e.g.,
Comparison Networks Sorting Sorting binary values
Searching and Sorting Recursion, Merge-sort, Divide & Conquer, Bucket sort, Radix sort Lecture 5.
Lecture 4 Sorting Networks. Comparator comparator.
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
Sorting. Sorting Sorting is important! Things that would be much more difficult without sorting: –finding a telephone number –looking up a word in the.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Sorting Networks Sorting.
 Design and Analysis of Algorithms تصميم وتحليل الخوارزميات (311 عال) Chapter 2 Sorting (insertion Sort, Merge Sort)
Sorting Quick, Merge & Radix Divide-and-conquer Technique subproblem 2 of size n/2 subproblem 1 of size n/2 a solution to subproblem 1 a solution to.
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes P i and P j send their elements to each other. Process P.
CMPT 238 Data Structures More on Sorting: Merge Sort and Quicksort.
Lecture 2 Algorithm Analysis
Merge Sort 1/12/2018 9:44 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Lecture 2 Sorting.
Sorting Networks Characteristics The basic unit: a comparator
Lecture 5 Dynamic Programming
Unit 1. Sorting and Divide and Conquer
Lecture 4 Divide-and-Conquer
SORTING NETWORKS.
Divide and Conquer.
Lecture 5 Dynamic Programming
Growth Functions Algorithms Lecture 8
Chapter 2: Getting Started
Lecture 3 Induction Algorithm design techniques: induction
Edmonds-Karp Algorithm
“Human Sorting” It’s a “Problem Solving” game:
Comparison Networks Sorting Sorting binary values
Ch 2: Getting Started Ming-Te Chi
Divide-and-Conquer 7 2  9 4   2   4   7
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Divide and Conquer Algorithms Part I
Lecture 6 Algorithm Analysis
Chapter 4.
Merge Sort 2/23/ :15 PM Merge Sort 7 2   7  2   4  4 9
Divide-and-Conquer 7 2  9 4   2   4   7
Merge Sort 4/10/ :25 AM Merge Sort 7 2   7  2   4  4 9
Divide & Conquer Algorithms
Solving recurrence equations
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
Merge Sort 5/30/2019 7:52 AM Merge Sort 7 2   7  2  2 7
CSCE 3110 Data Structures & Algorithm Analysis
“Human Sorting” It’s a “Problem Solving” game:
Presentation transcript:

Lecture 4 Sorting Networks

Comparator comparator

A Sorting Network 9 5 2 2 5 9 6 5 2 2 5 6 6 6 9 9 A sorting network is a comparison network which output monotone nondecreasing sequence for every input.

Depth 9 5 2 2 5 9 6 5 2 2 5 6 6 6 9 9 Depth is the maximum number of comparators on a path from an input wire to an output wire.

Depth = parallel time 9 5 2 2 5 9 6 5 2 2 5 6 6 6 9 9 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 Merging network Sorting 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 1 1 bitonic 1 1 bitonic 1 1

The half-cleaner bitonic 1 1 1 bitonic 1 1 1 1 bitonic clean 1 1 1

Lemma One of two halfs is bitonic clean. every number in the 1st half ≤ any element in the 2nd half.

Proof (case 1) 1 1 1

Proof (case 2) 1 1 1

Proof (case 3) 1 1 1 1 1

Proof (case 4) 1 1 1 1 1

Proof (case 5) 1 1 1 1 1 1 1 1

Proof (case 6) 1 1 1 1 1 1 1 1

Proof (case 7) 1 1 1 1 1 1

Proof (case 8) 1 1 1 1 1 1

bitonic sorted Half cleaners

sorted 1 sorted 1 sorted 1 1 1 1 Half cleaners Merging Network

Structure Sorting network Merging network Sorting network

Sorting Network Merging Networks

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 n n n n m

Rearrangeability Theorem

Network with 2x2 crossbars

Puzzle