Bitonic and Merging sorting networks

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

Lecture 19: Parallel Algorithms
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
Pairwise Cardinality Networks Michael Codish and Moshe Zazon-Ivry Department of Computer Science B en-Gurion University.
Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different.
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.
Sorting. Input: A sequence of n numbers a 1, …, a n Output: A reordering a 1 ’, …, a n ’, such that a 1 ’ < … < a n ’
1 Lecture 25: Parallel Algorithms II Topics: matrix, graph, and sort algorithms Tuesday presentations:  Each group: 10 minutes  Describe the problem,
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
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 Parallel Algorithms III Topics: graph and sort algorithms.
Mesh connected networks. Sorting algorithms Efficient Parallel Algorithms COMP308.
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.
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
Sorting and Searching Arrays CSC 1401: Introduction to Programming with Java Week 12 – Lectures 1 & 2 Wanda M. Kunkle.
ALGORITHM ANALYSIS AND DESIGN INTRODUCTION TO ALGORITHMS CS 413 Divide and Conquer Algortihms: Binary search, merge sort.
Section 8.4 Insertion Sort CS Insertion Sort  Another quadratic sort, insertion sort, is based on the technique used by card players to arrange.
Counting Inversions Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Outline  introduction  Sorting Networks  Bubble Sort and its Variants 2.
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.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
1 Parallel Sorting Algorithm. 2 Bitonic Sequence A bitonic sequence is defined as a list with no more than one LOCAL MAXIMUM and no more than one LOCAL.
“Sorting networks and their applications”, AFIPS Proc. of 1968 Spring Joint Computer Conference, Vol. 32, pp
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
1 Sorting Networks Sorting.
Chapter 4, Part II Sorting Algorithms. 2 Heap Details A heap is a tree structure where for each subtree the value stored at the root is larger than all.
PREVIOUS SORTING ALGORITHMS  BUBBLE SORT –Time Complexity: O(n 2 ) For each item, make (n –1) comparisons Gives: Comparisons = (n –1) + (n – 2)
+ Even Odd Sort & Even-Odd Merge Sort Wolfie Herwald Pengfei Wang Rachel Celestine.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Merge Sort Comparison Left Half Data Movement Right Half Sorted.
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.
(Proof By) Induction Recursion
Advanced Algorithms Analysis and Design
Prof. U V THETE Dept. of Computer Science YMA
Lecture 4 Sorting Networks
Mesh connected networks. Sorting algorithms
Sorting Networks Characteristics The basic unit: a comparator
7.1 What is a Sorting Network?
Unit 1. Sorting and Divide and Conquer
SORTING NETWORKS.
Lecture 22: Parallel Algorithms
Merge Sort Merge sort is a recursive algorithm for sorting that decomposes the large problem.
Bitonic Sorting and Its Circuit Design
Divide and Conquer (Merge Sort)
Comparison Networks Sorting Sorting binary values
Richard Anderson Lecture 13 Divide and Conquer
Lecture 6 Algorithm Analysis
Divide and Conquer Algorithms Part I
Lecture 6 Algorithm Analysis
Divide-and-Conquer 7 2  9 4   2   4   7
Application: Efficiency of Algorithms II
Richard Anderson Lecture 14 Divide and Conquer
Application: Efficiency of Algorithms II
Richard Anderson Lecture 14, Winter 2019 Divide and Conquer
Richard Anderson Lecture 14 Divide and Conquer
Richard Anderson Lecture 13 Divide and Conquer
Efficient Parallel Algorithms COMP308
Algorithms and Data Structures Lecture II
Presentation transcript:

Bitonic and Merging sorting networks Lecture 16 Efficient Parallel Algorithms COMP308

Bitonic sequence Bitonic sequence is a sequence that For example either monotonically increases and the then monotonically decreases, or else monotonically decreases and then monotonically increases. For example <1,4,6,8,3,2> <9,8,3,2,4,6> are both bitonic The zero-one sequences that are bitonic have a simple structure. They have the form 0i1j0k or the form 1i0j1k, for some i,k,j0.

The half-cleaner The bitonic sorter is comprised of several stages, each of which is called a half-cleaner. Each half-cleaner is a comparison network of depth 1 in which input line i is compared with line i + n/2 for i = 1,2,…,n/2. When a bitonic sequence of 0’s and 1’s is applied as input to a half-cleaner, the half-cleaner produces an output sequence in which smaller values are in the top half, larger values are in the bottom half, and both halves are bitonic.

The comparison network Half-cleaner 1 1 1 1 bitonic clean bitonic bitonic bitonic bitonic bitonic clean

In fact at least one of the halves is clean – consisting all 0’s or all 1’s. The next lemma proves these properties of half-cleaners. Lemma. If the input to a halve-cleaner is a bitonic sequence of 0’s and 1’s, then the output satisfies the following properties: both the top and the bottom half are bitonic, every element in the top half is at least as small as every element of the bottom half, and at least one half is clear.

Proof:

The bitonic sorter By recursively combining half-cleaners we can build a bitonic sorter, which is a network that sorts bitonic sequences. The first stage of bitonic-sorter[n] is half-cleaner[n] , which produces two bitonic sequences. Thus we can complete the sort by using two copies of bitonic-sorter[n/2]

A Merging Network Our sorting network will be constructed from merging networks, which are networks that can merge two sorted sequences into one sorted output sequence. We modify the first half cleaner in the Bitonic-sorter[n]

A network that merges two sorted input sequences into one sorted output sequence Merger Bitonic sorter Bitonic sorter

Sorting network Sorter [n/2] Merger 1 2 2 3 4 4 4 4 5 5 6