Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.

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
Parallel Sorting Sathish Vadhiyar. Sorting  Sorting n keys over p processors  Sort and move the keys to the appropriate processor so that every key.
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
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.
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 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 ’
CSC 2300 Data Structures & Algorithms March 27, 2007 Chapter 7. Sorting.
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,
1 Merge Sort Merge Sort Reading p A Sorting Pattern The most efficient sorting algorithms all seem to follow a divide-and-conquer strategy.
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.
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.
Subway Network Algorithm Matt Freeburg ICS 311 Fall 2006 University of Hawai’i at Manoa.
Triangulating a monotone polygon
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
A Simple Algorithm for Stable Minimum Storage Merging Pok-Son Kim Kookmin University, Department of Mathematics, Seoul , Korea Arne Kutzner Seokyeong.
Outline  introduction  Sorting Networks  Bubble Sort and its Variants 2.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
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.
CSC317 1 So far so good, but can we do better? Yes, cheaper by halves... orkbook/cheaperbyhalf.html.
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.
Sorting Ordering data. Design and Analysis of Sorting Assumptions –sorting will be internal (in memory) –sorting will be done on an array of elements.
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?
SORTING NETWORKS.
MergeSort Source: Gibbs & Tamassia.
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
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Divide and Conquer Algorithms Part I
Lecture 6 Algorithm Analysis
Application: Efficiency of Algorithms II
Application: Efficiency of Algorithms II
Richard Anderson Lecture 14 Divide and Conquer
Richard Anderson Lecture 13 Divide and Conquer
Efficient Parallel Algorithms COMP308
Presentation transcript:

Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308

Bitonic sequence Bitonic sequence is a sequence that –either monotonically increases and the then monotonically decreases, –or else monotonically decreases and then monotonically increases. For example – – are both bitonic The zero-one sequences that are bitonic have a simple structure. They have the form 0 i 1 j 0 k or the form 1 i 0 j 1 k, 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 bitonic bitonic clean bitonic bitonic clean bitonic

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 Bitonic sorter Bitonic sorter Merger

Sorting network Sorter [n/2] Merger