Lecture 4 Sorting Networks. Comparator comparator.

Slides:



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

AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
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.
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
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.
Sorting. Input: A sequence of n numbers a 1, …, a n Output: A reordering a 1 ’, …, a n ’, such that a 1 ’ < … < a n ’
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.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
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.
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Lecture 5 Dynamic Programming. Dynamic Programming Self-reducibility.
Lecture 2 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Designing algorithms There are many ways to design an algorithm. Insertion sort uses an incremental approach: having sorted the sub-array A[1…j - 1],
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.
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.
2IS80 Fundamentals of Informatics Fall 2015 Lecture 6: Sorting and Searching.
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.
CS6045: Advanced Algorithms Sorting Algorithms. Sorting Input: sequence of numbers Output: a sorted sequence.
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.
Lecture 4 Sorting Networks
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.
Growth Functions Algorithms Lecture 8
Chapter 2: Getting Started
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
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
Divide & Conquer Algorithms
Solving recurrence equations
Merge Sort 5/30/2019 7:52 AM Merge Sort 7 2   7  2  2 7
“Human Sorting” It’s a “Problem Solving” game:
Presentation transcript:

Lecture 4 Sorting Networks

Comparator comparator

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

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

Depth = parallel time 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 Sorting network Merging 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 bitonic

The half-cleaner bitonic clean bitonic

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

Proof (case 1)

Proof (case 2)

Proof (case 3)

Proof (case 4)

Proof (case 5)

Proof (case 6)

Proof (case 7)

Proof (case 8)

Half cleaners bitonicsorted

Half cleaners sorted Merging Network

Structure Sorting network Sorting network Merging network

Merging Networks Sorting Network

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

Rearrangeability Theorem

Network with 2x2 crossbars

Puzzle