Cole s MergeSort. prof. Ing. Pavel Tvrdík CSc. Fakulta informačních technologií České vysoké učení technické v Praze c Pavel Tvrdík, 2010
|
|
- Audra Hampton
- 5 years ago
- Views:
Transcription
1 Cole s MergeSort prof. Ing. Pavel Tvrdík CSc. Katedra počítačových systémů Fakulta informačních technologií České vysoké učení technické v Praze c Pavel Tvrdík, 2010 Pokročilé paralelní algoritmy (PI-PPA) LS 2010/11, Seminář 3 Evropský sociální fond. Praha & EU: Investujeme do vaší budoucnosti prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 1 / 27
2 Standard MergeSort Algorithms Even-Odd MergeSort Standard sorting on hypercubic networks Batcher s algorithms: Even-Odd MergeSort, Bitonic MergeSort. Even-Odd MergeSort (EOMS) a 0 a 1 EOMS(N) EOMS(2N) a EOM(N,N) EOM(N/2,N/2) a N 1 a N a N+1 EOM(N,N) a N 2 N 1 b b b EOM(N/2,N/2) EOMS(N) a 2N 1 b N 2 N 1 EOMS(a 0,..., a 2N 1 ) = EOMerge(EOMS(a 0,..., a N 1 ), EOMS(a N,..., a 2N 1 )). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 2 / 27
3 Standard MergeSort Algorithms Even-Odd Merge Even-Odd Merge (EOM) A B a a N 2 N 1 b b b b N 2 N 1 interleave CE EOM(N,N) EOM(N/2,N/2) EOM(N/2,N/2) C L L D C = EOMerge(even(A), odd(b)) D = EOMerge(odd(A), even(b)) L = Interleave(C, D) L = EOMerge(A, B) = Pairwise CE(L ) prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 3 / 27
4 Standard MergeSort Algorithms Correctness and parallel complexity of EOM Correctness and parallel complexity Lemma 1 EOM merges 2 sorted sequences A, B of length N in log N + 1 parallel CE steps using N(log N + 1) comparators. Proof. (By 0-1 Sorting Lemma.) The lemma holds for N = 1. Let N = 2 k, k 1. Let α and β be the # of zeros in A and B, resp. Then the # of zeros in C and D is γ = α/2 + β/2 and δ = α/2 + β/2, resp. Hence, γ δ 1. Therefore, the # of 0 s in C and D can differ by at most one. One comparator column can fix the only one possible misordered pair. prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 4 / 27
5 Standard MergeSort Algorithms Correctness and parallel complexity of EOM d m (2) = 1 & d m (2N) = d m (N) + 1 d m (2N) = log N + 1 = log(2n), c m (2N) = Nd m (2N) = N log(2n). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 5 / 27
6 Standard MergeSort Algorithms Parallel complexity analysis of EOMS Time and cost complexity of EOMS Lemma 2 EOMS sorts N numbers in O(log 2 N) parallel CE steps using O(N log 2 N) comparators. d s (2) = 1 & d s (2N) = d s (N) + d m (2N) = d s (N) + log(2n) d s (N) = log N(log N + 1)/2 = O(log 2 N). c s (2) = 1 & c s (2N) = 2c s (N) + c m (2N) = 2c s (N) + N log(2n) c s (N) = Nd s (N)/2 = O(N log 2 N). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 6 / 27
7 Standard MergeSort Algorithms EOMS iteratively Unfolded EOMS EOMS treats the input sequence as a sequence of N pairs. By passing through a comparator, each pair becomes a sorted subsequence of length 2. These subsequences are then merged into N/2 sorted subsequences of length 4, and so on. In the last merge step, two ascending sequences of length N are merged into the final ascending sequence of length 2N prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 7 / 27
8 Standard MergeSort Algorithms Even-Even MergeSort Even-Even MergeSort (EEMS) where EEMS(a 0,..., a 2N 1 ) = EEMerge(EEMS(a 0,..., a N 1 ), EEMS(a N,..., a 2N 1 )). EEMerge(A, B) = Pairwise CE(Even Odd Interleave(C, D)) C = EEMerge(even(A), even(b)) D = EEMerge(odd(A), odd(b)) a 0 a 1 EEMS(N) EEMS(2N) a 3 EEM(N,N) EEM(N/2,N/2) interleave CE a N 1 a N a N+1 EEMS(N) EEM(N,N) N 2 a N 1 b0 b1 b2 b3 EEM(N/2,N/2) a 2N 1 N 2 bn 1 (a) (b) prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 8 / 27
9 Standard MergeSort Algorithms Non-binary proofs of EEMS Non-binary proof of the standard EEMS Lemma 3 Let Then where N = 2 k, L[1,..., N] and R[1,..., N] = monotonic sequences, Z = EEMerge(L, R) = merge of L and R of length 2N. Z = Pairwise CE(Even Odd Interleave(OM, EM)), EM[1,..., N] = EEMerge(even(L), even(r)), OM[1,..., N] = EEMerge(odd(L), odd(r)). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 9 / 27
10 Standard MergeSort Algorithms Non-binary proofs of EEMS Proof.. 1 N L: R: EM: i? OM: i i+ 2 N i N i 1 The only uncertain number in OM with respect to EM[i] is OM[i + 1] we just need CE(EM[i], OM[i + 1]) to put these two numbers in order. prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 10 / 27
11 Standard MergeSort Algorithms Non-binary proofs of EEMS Yet another proof of the standard EEMS Lemma 4 Let z = EM[i] and j = the original index of z in its original input sequence, say L, f(z) = the final position of z in the final sequence Z. Then 2i f(z) 2i + 1. Proof.. L: 2 j R: EM: i?? Z: i 1 2N 2 i 1 prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 11 / 27
12 Standard MergeSort Algorithms Problem analysis Problem analysis What can be said about OM if we have only EM? In general, very little. L: R: EM: Z: ??????? 29 But with some additional O(N) computation, we can determine exactly the final positions of the odd-positioned numbers without performing the operation EEMerge(odd(A), odd(b)). 7 prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 12 / 27
13 The main idea The main idea of the cost-optimal EREW PRAM MergeSort In each level of EEMS, apply recursively only 1 even-even merge operation. Perform some auxiliary O(N) computations to find the final positions for all numbers in L R. Then the # of CE operations for the merge operation of 2N numbers is c m (2N) = c m (N) + O(N). This equation has solution since c m (2N) = O(N), N + N/2 + N/ = 2N. Therefore, the total # of CE operations of the whole EEMS algorithm is then c s (2N) = 2c s (N) + c m (2N) = O(N log N). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 13 / 27
14 Pseudocode Pseudocode of the Cole s EREW PRAM MergeSort function EffMerge(L, R) returns Z; input EM, L, R: array[1,..., N] of T = record {V al : int; Origin : {L, R}; OrigIndex : int}; output Z: array[1,..., 2N] of T ; auxiliary OrP I, OpP I: array[1,..., N] of int; ( OrP I[i] = index of predecessor of EM[i].V al in its original array EM[i].Origin ) ( OpP I[i] = index of predecessor of EM[i].V al in the opposite than the original array ) LP I, RP I: array[1,..., N] of int; ( LP I[i] = index of predecessor of EM[i].V al in L ) ( RP I[i] = index of predecessor of EM[i].V al in R ) LEMP I, REMP I: array[1,..., N] of int; ( LEMP I[i] = index of predecessor of L[i].V al, i is odd, in EM ) ( REMP I[i] = index of predecessor of R[i].V al, i is odd, in EM ) prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 14 / 27
15 Pseudocode F I: array[1,..., 2N] of int; ( F I = final indexes of numbers from L R in Z ) begin ( merge recursively the even-numbered subsequences ) EM = EffMerge(even(L), even(r)); ( Phase A: calculate indexes of predecessors for all numbers from EM in L and R ) i = 1,..., N do in parallel { OrP I[i] := EM[i].OrigIndex 1; OpP I[i] := 2i EM[i].OrigIndex; if (EM[i].Origin = L) then { if (OpP I[i] < N and R[OpP I[i] + 1].V al < EM[i].V al) then OpP I[i] + +} else { if (OpP I[i] < N and L[OpP I[i] + 1].V al < EM[i].V al) then OpP I[i] + +}; } prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 15 / 27
16 Pseudocode ( Phase B: rename arrays ) i = 1,..., N do in parallel if (EM[i].Origin = L) then {LP I[i] := OrP I[i]; RP I[i] := OpP I[i]} else {LP I[i] := OpP I[i]; RP I[i] := OrP I[i]} ( Phase C: calculate indexes of predecessors in EM for all elements from L R EM ) i = 1,..., N do in parallel { if (LP I[i 1] < LP I[i] and LP I[i] is odd) then LEMP I[LP I[i]] := i 1; if (RP I[i 1] < RP I[i] and RP I[i] is odd) then REMP I[RP I[i]] := i 1; } prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 16 / 27
17 Pseudocode ( Phase D: calculate the final positions in Z ) ( D1: calculation for EM ) i = 1,..., N do in parallel { F I[i] := LP I[i] + RP I[i] + 1; Z[F I[i]] := EM[i]; } ( D2: calculation for L EM ) i = 1,..., N 1 do in parallel { j := LEMP I[i]; if (L[i].V al > R[RP I[j + 1]].V al) then F I[i] := i + RP I[j + 1] else F I[i] := i + RP I[j + 1] 1; Z[F I[i]] := L[i]; } ( D3: calculation for R EM ) i = 1,..., N 1 do in parallel { j := REMP I[i]; if (R[i].V al > L[LP I[j + 1]].V al) then F I[i] := i + LP I[j + 1] else F I[i] := i + LP I[j + 1] 1; Z[F I[i]] := R[i]; } end prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 17 / 27
18 Correctness proofs Proof of the correctness of Cole s MergeSort Phase A OpPI: EM: i=5 L: R: ? 2 i j j=4 EM: OpPI: L: R: prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 18 / 27
19 Correctness proofs Phase B EM: LPI: RPI: L: R: prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 19 / 27
20 Correctness proofs Span of RP I and LP I Lemma 5 The maximal span between adjacent LPI s or RPI s is at most 2. Proof. Case (a): e 1 < e < o 1 < e 2 < o 2 < e e < e 2 < e Case (b): o 1 < e e 1 < o 2 < e 2 < e e < e 2 < e. EM: LPI i 1 i i 1 i e e EM: e e LPI LPI LPI L: e1 o1 e2 o2 L: o1 e1 o2 e2 (a) (b) prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 20 / 27
21 Correctness proofs Phase C Case (a): x < e < z < e y. Case (b): e x & x < e x must appear in EM before e, but not before e x = e LEMP I[j] = i 1. Case (c): EM: L: EM: L: cannot appear due to the Lemma. i 1 i i 1 i i 1 i e e EM: e e EM: e e LPI LPI LPI LPI LPI LPI x z y L: y x z L: u y x z j 1 j j+1 j 2 j 1 j j 3j 2 j 1 j LEMPI i 1 i i 1 i e e EM: e e LEMPI x z y L: y x z j 1 j j+1 j 2 j 1 j prof. Pavel Tvrdík (FIT(a) ČVUT) Cole(b) MS PI-PPA, 2011, Seminář 3 21 / 27 (c)
22 Correctness proofs The indexes LEMP I and REMP I LEMPI: EM: REMPI: L: R: prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 22 / 27
23 Correctness proofs Phase D2 Calculate numbers in L EM the # of predecessor in R. Trivially, k > e & e > r k > r. k e & e r k r. j j+1 EM: e e LEMPI[i] RPI[j] L: k R: i RPI[j+1] r r r k k It follows that interval (r, r contains at most two numbers. prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 23 / 27
24 Correctness proofs Case analysis EM: j j+1 e e EM: j j+1 e e LEMPI[i] RPI[j] RPI[j+1] LEMPI[i] RPI[j] RPI[j+1] L: k i R: (a) r e r r? L: k i R: (b) r o r r EM: j j+1 e e EM: j j+1 e e LEMPI[i] RPI[j] RPI[j+1] LEMPI[i] RPI[j] RPI[j+1] L: k i R: (c) r r r L: k R: r r r i (d)? prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 24 / 27
25 Complexity analysis Complexity of Cole s EREW PRAM MergeSort Theorem 6 EffMerge(N, N) requires 4N CE s and its parallel time is T (2N, N) = O(log N). Proof. Phases A and C perform at most N comparisons plus some O(1) operations per number. The same for Phase D. c m (2N) c m (N) + 2N c m (2N) 4N. p = N one stage takes O(1) time. The # of stages = O(log N). prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 25 / 27
26 Complexity analysis Theorem 7 EffMerge(N, N) takes parallel time O(log N) using N/ log N processors. Proof. log N numbers per processor. The first stage takes α log N parallel CE s plus auxiliary operations, α 4. The 1st recursive call of EffMerge takes (α log N)/2. The 2nd recursive call (α log N)/4, and so on. The log log N-th recursive call the # of numbers = N/ log N at most one number per processor O(1) time. The total time is T (2N, N/ log N) = αo (log N + (log N)/2 + (log N)/ where the # of nonconstant terms is log log N and the remaining log N log log N terms are O(1) T (2N, N/ log N) α3 log N. prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 26 / 27
27 Complexity analysis Theorem 8 The Cole s MergeSort performs at most 2N log N comparisons to sort N numbers, it runs in parallel time O(log 2 N) using N/ log N processors. Proof. The total # of CE operations per stage is at most 2N (EffMerge of two sequences of length N/2). The # of merge stages is log N. Each stage takes parallel time log N on N/ log N processors. prof. Pavel Tvrdík (FIT ČVUT) Cole MS PI-PPA, 2011, Seminář 3 27 / 27
Markovské řetězce se spojitým parametrem
Markovské řetězce se spojitým parametrem Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Katedra počítačových systémů Katedra teoretické informatiky Fakulta informačních technologií České
More informationBootstrap metody II Kernelové Odhady Hustot
Bootstrap metody II Kernelové Odhady Hustot Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Katedra počítačových systémů Katedra teoretické informatiky Fakulta informačních technologií České
More informationZáklady teorie front II
Základy teorie front II Aplikace Poissonova procesu v teorii front Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Katedra počítačových systémů Katedra teoretické informatiky Fakulta informačních
More informationComputational intelligence methods
Computational intelligence methods GA, schemas, diversity Pavel Kordík, Martin Šlapák Katedra teoretické informatiky FIT České vysoké učení technické v Praze MI-MVI, ZS 2011/12, Lect. 5 https://edux.fit.cvut.cz/courses/mi-mvi/
More informationQuantum computing. Jan Černý, FIT, Czech Technical University in Prague. České vysoké učení technické v Praze. Fakulta informačních technologií
České vysoké učení technické v Praze Fakulta informačních technologií Katedra teoretické informatiky Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti MI-MVI Methods of Computational Intelligence(2010/2011)
More informationStatistika pro informatiku
Statistika pro informatiku prof. RNDr. Roman Kotecký DrSc., Dr. Rudolf Blažek, PhD Katedra teoretické informatiky FIT České vysoké učení technické v Praze MI-SPI, ZS 2011/12, Přednáška 5 Evropský sociální
More informationComputational Intelligence Methods
Computational Intelligence Methods Ant Colony Optimization, Partical Swarm Optimization Pavel Kordík, Martin Šlapák Katedra teoretické informatiky FIT České vysoké učení technické v Praze MI-MVI, ZS 2011/12,
More informationBinary Decision Diagrams
Binary Decision Diagrams Logic Circuits Design Seminars WS2010/2011, Lecture 2 Ing. Petr Fišer, Ph.D. Department of Digital Design Faculty of Information Technology Czech Technical University in Prague
More informationStatistika pro informatiku
Statistika pro informatiku prof. RNDr. Roman Kotecký DrSc., Dr. Rudolf Blažek, PhD Katedra teoretické informatiky FIT České vysoké učení technické v Praze MI-SPI, ZS 2011/12, Přednáška 2 Evropský sociální
More informationZáklady teorie front
Základy teorie front Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Katedra počítačových systémů Katedra teoretické informatiky Fakulta informačních technologií České vysoké učení technické
More informationNonlinearOptimization
1/35 NonlinearOptimization Pavel Kordík Department of Computer Systems Faculty of Information Technology Czech Technical University in Prague Jiří Kašpar, Pavel Tvrdík, 2011 Unconstrained nonlinear optimization,
More informationCOL 730: Parallel Programming
COL 730: Parallel Programming PARALLEL SORTING Bitonic Merge and Sort Bitonic sequence: {a 0, a 1,, a n-1 }: A sequence with a monotonically increasing part and a monotonically decreasing part For some
More informationR ij = 2. Using all of these facts together, you can solve problem number 9.
Help for Homework Problem #9 Let G(V,E) be any undirected graph We want to calculate the travel time across the graph. Think of each edge as one resistor of 1 Ohm. Say we have two nodes: i and j Let the
More informationMultilevel Logic Synthesis Algebraic Methods
Multilevel Logic Synthesis Algebraic Methods Logic Circuits Design Seminars WS2010/2011, Lecture 6 Ing. Petr Fišer, Ph.D. Department of Digital Design Faculty of Information Technology Czech Technical
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Chapter 2 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: Room 5326, Engineering Building, Thursday 4:30pm -
More information1 Substitution method
Recurrence Relations we have discussed asymptotic analysis of algorithms and various properties associated with asymptotic notation. As many algorithms are recursive in nature, it is natural to analyze
More informationMI-RUB Testing II Lecture 11
MI-RUB Testing II Lecture 11 Pavel Strnad pavel.strnad@fel.cvut.cz Dept. of Computer Science, FEE CTU Prague, Karlovo nám. 13, 121 35 Praha, Czech Republic MI-RUB, WS 2011/12 Evropský sociální fond Praha
More informationMI-RUB Testing Lecture 10
MI-RUB Testing Lecture 10 Pavel Strnad pavel.strnad@fel.cvut.cz Dept. of Computer Science, FEE CTU Prague, Karlovo nám. 13, 121 35 Praha, Czech Republic MI-RUB, WS 2011/12 Evropský sociální fond Praha
More informationDivide and Conquer. Recurrence Relations
Divide and Conquer Recurrence Relations Divide-and-Conquer Strategy: Break up problem into parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. 2 MergeSort Mergesort.
More informationBranch-and-Bound Algorithm. Pattern Recognition XI. Michal Haindl. Outline
Branch-and-Bound Algorithm assumption - can be used if a feature selection criterion satisfies the monotonicity property monotonicity property - for nested feature sets X j related X 1 X 2... X l the criterion
More informationStatistika pro informatiku
Statistika pro informatiku prof. RNDr. Roman Kotecký DrSc., Dr. Rudolf Blažek, PhD Katedra teoretické informatiky FIT České vysoké učení technické v Praze MI-SPI, ZS 2011/12, Přednáška 1 Evropský sociální
More informationLecture 6 September 21, 2016
ICS 643: Advanced Parallel Algorithms Fall 2016 Lecture 6 September 21, 2016 Prof. Nodari Sitchinava Scribe: Tiffany Eulalio 1 Overview In the last lecture, we wrote a non-recursive summation program and
More informationTopic 17. Analysis of Algorithms
Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm
More informationStrategies for Stable Merge Sorting
Strategies for Stable Merge Sorting Preliminary version. Comments appreciated. Sam Buss sbuss@ucsd.edu Department of Mathematics University of California, San Diego La Jolla, CA, USA Alexander Knop aknop@ucsd.edu
More informationEE/CSCI 451: Parallel and Distributed Computation
EE/CSCI 451: Parallel and Distributed Computation Lecture #19 3/28/2017 Xuehai Qian Xuehai.qian@usc.edu http://alchem.usc.edu/portal/xuehaiq.html University of Southern California 1 From last class PRAM
More informationQuicksort. Where Average and Worst Case Differ. S.V. N. (vishy) Vishwanathan. University of California, Santa Cruz
Quicksort Where Average and Worst Case Differ S.V. N. (vishy) Vishwanathan University of California, Santa Cruz vishy@ucsc.edu February 1, 2016 S.V. N. Vishwanathan (UCSC) CMPS101 1 / 28 Basic Idea Outline
More informationNotation. Pattern Recognition II. Michal Haindl. Outline - PR Basic Concepts. Pattern Recognition Notions
Notation S pattern space X feature vector X = [x 1,...,x l ] l = dim{x} number of features X feature space K number of classes ω i class indicator Ω = {ω 1,...,ω K } g(x) discriminant function H decision
More informationImproving the Average Delay of Sorting
Improving the Average Delay of Sorting Andreas Jakoby Maciej Liśkiewicz Rüdiger Reischuk Christian Schindelhauer Inst. für Theoretische Informatik, Universität zu Lübeck, Germany jakoby/liskiewi/reischuk@tcs.mu-luebeck.de
More informationOn Fast Bitonic Sorting Networks
On Fast Bitonic Sorting Networks Tamir Levi Ami Litman January 1, 2009 Abstract This paper studies fast Bitonic sorters of arbitrary width. It constructs such a sorter of width n and depth log(n) + 3,
More informationDivide and Conquer Algorithms
Divide and Conquer Algorithms T. M. Murali March 17, 2014 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine solutions
More informationCost-Constrained Matchings and Disjoint Paths
Cost-Constrained Matchings and Disjoint Paths Kenneth A. Berman 1 Department of ECE & Computer Science University of Cincinnati, Cincinnati, OH Abstract Let G = (V, E) be a graph, where the edges are weighted
More informationParallel Recursion: Powerlists. Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin
Parallel Recursion: Powerlists Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Overview Definition of a powerlist Basic operations on
More informationMI-RUB Exceptions Lecture 7
MI-RUB Exceptions Lecture 7 Pavel Strnad pavel.strnad@fel.cvut.cz Dept. of Computer Science, FEE CTU Prague, Karlovo nám. 13, 121 35 Praha, Czech Republic MI-RUB, WS 2011/12 Evropský sociální fond Praha
More information1 Some loose ends from last time
Cornell University, Fall 2010 CS 6820: Algorithms Lecture notes: Kruskal s and Borůvka s MST algorithms September 20, 2010 1 Some loose ends from last time 1.1 A lemma concerning greedy algorithms and
More informationV. Adamchik 1. Recurrences. Victor Adamchik Fall of 2005
V. Adamchi Recurrences Victor Adamchi Fall of 00 Plan Multiple roots. More on multiple roots. Inhomogeneous equations 3. Divide-and-conquer recurrences In the previous lecture we have showed that if the
More informationCOMP 633: Parallel Computing Fall 2018 Written Assignment 1: Sample Solutions
COMP 633: Parallel Computing Fall 2018 Written Assignment 1: Sample Solutions September 12, 2018 I. The Work-Time W-T presentation of EREW sequence reduction Algorithm 2 in the PRAM handout has work complexity
More informationFind an Element x in an Unsorted Array
Find an Element x in an Unsorted Array What if we try to find a lower bound for the case where the array is not necessarily sorted? J.-L. De Carufel (U. of O.) Design & Analysis of Algorithms Fall 2017
More informationLecture 14: Nov. 11 & 13
CIS 2168 Data Structures Fall 2014 Lecturer: Anwar Mamat Lecture 14: Nov. 11 & 13 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 14.1 Sorting
More informationCSCI Honor seminar in algorithms Homework 2 Solution
CSCI 493.55 Honor seminar in algorithms Homework 2 Solution Saad Mneimneh Visiting Professor Hunter College of CUNY Problem 1: Rabin-Karp string matching Consider a binary string s of length n and another
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lecture 6-8 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationRecurrence Relations
Recurrence Relations Winter 2017 Recurrence Relations Recurrence Relations A recurrence relation for the sequence {a n } is an equation that expresses a n in terms of one or more of the previous terms
More informationSection 5.3 Divide and Conquer Relations. 0,a m. - Division into thirds gives m = 3. Apply the telescoping technique described in Section 5.2.
Section 5.3 Divide and Conquer Relations The form: a n = αa n/m + f (n) The sequence: {a m 0,a m 1,a m 2,...,a m k,...} n = mk for some k. - Division of the problem in half gives m =2 - Division into thirds
More informationNeural Nets in PR. Pattern Recognition XII. Michal Haindl. Outline. Neural Nets in PR 2
Neural Nets in PR NM P F Outline Motivation: Pattern Recognition XII human brain study complex cognitive tasks Michal Haindl Faculty of Information Technology, KTI Czech Technical University in Prague
More informationSorting. Chapter 11. CSE 2011 Prof. J. Elder Last Updated: :11 AM
Sorting Chapter 11-1 - Sorting Ø We have seen the advantage of sorted data representations for a number of applications q Sparse vectors q Maps q Dictionaries Ø Here we consider the problem of how to efficiently
More informationShortest paths with negative lengths
Chapter 8 Shortest paths with negative lengths In this chapter we give a linear-space, nearly linear-time algorithm that, given a directed planar graph G with real positive and negative lengths, but no
More informationOutline. 1 Introduction. Merging and MergeSort. 3 Analysis. 4 Reference
Outline Computer Science 331 Sort Mike Jacobson Department of Computer Science University of Calgary Lecture #25 1 Introduction 2 Merging and 3 4 Reference Mike Jacobson (University of Calgary) Computer
More informationRecap: Prefix Sums. Given A: set of n integers Find B: prefix sums 1 / 86
Recap: Prefix Sums Given : set of n integers Find B: prefix sums : 3 1 1 7 2 5 9 2 4 3 3 B: 3 4 5 12 14 19 28 30 34 37 40 1 / 86 Recap: Parallel Prefix Sums Recursive algorithm Recursively computes sums
More informationMethods for solving recurrences
Methods for solving recurrences Analyzing the complexity of mergesort The merge function Consider the following implementation: 1 int merge ( int v1, int n1, int v, int n ) { 3 int r = malloc ( ( n1+n
More informationLecture 10. Sublinear Time Algorithms (contd) CSC2420 Allan Borodin & Nisarg Shah 1
Lecture 10 Sublinear Time Algorithms (contd) CSC2420 Allan Borodin & Nisarg Shah 1 Recap Sublinear time algorithms Deterministic + exact: binary search Deterministic + inexact: estimating diameter in a
More informationAsymptotic Running Time of Algorithms
Asymptotic Complexity: leading term analysis Asymptotic Running Time of Algorithms Comparing searching and sorting algorithms so far: Count worst-case of comparisons as function of array size. Drop lower-order
More informationCOMP 250 Fall Midterm examination
COMP 250 Fall 2004 - Midterm examination October 18th 2003, 13:35-14:25 1 Running time analysis (20 points) For each algorithm below, indicate the running time using the simplest and most accurate big-oh
More informationCSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015 Today Registration should be done. Homework 1 due 11:59pm next Wednesday, April 8 th. Review math
More informationFinding a longest common subsequence between a run-length-encoded string and an uncompressed string
Journal of Complexity 24 (2008) 173 184 www.elsevier.com/locate/jco Finding a longest common subsequence between a run-length-encoded string and an uncompressed string J.J. Liu a, Y.L. Wang b,, R.C.T.
More informationDivide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,
Divide and Conquer CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Merging sorted lists: WHAT Given two sorted lists a 1 a 2 a 3 a k b 1 b 2 b 3 b
More informationITEC2620 Introduction to Data Structures
ITEC2620 Introduction to Data Structures Lecture 6a Complexity Analysis Recursive Algorithms Complexity Analysis Determine how the processing time of an algorithm grows with input size What if the algorithm
More informationAlgorithm. Executing the Max algorithm. Algorithm and Growth of Functions Benchaporn Jantarakongkul. (algorithm) ก ก. : ก {a i }=a 1,,a n a i N,
Algorithm and Growth of Functions Benchaporn Jantarakongkul 1 Algorithm (algorithm) ก ก ก ก ก : ก {a i }=a 1,,a n a i N, ก ก : 1. ก v ( v ก ก ก ก ) ก ก a 1 2. ก a i 3. a i >v, ก v ก a i 4. 2. 3. ก ก ก
More informationCOL106: Data Structures and Algorithms (IIT Delhi, Semester-II )
1 Solve the following recurrence relations giving a Θ bound for each of the cases 1 : (a) T (n) = 2T (n/3) + 1; T (1) = 1 (Assume n is a power of 3) (b) T (n) = 5T (n/4) + n; T (1) = 1 (Assume n is a power
More informationDivide-and-Conquer. Reading: CLRS Sections 2.3, 4.1, 4.2, 4.3, 28.2, CSE 6331 Algorithms Steve Lai
Divide-and-Conquer Reading: CLRS Sections 2.3, 4.1, 4.2, 4.3, 28.2, 33.4. CSE 6331 Algorithms Steve Lai Divide and Conquer Given an instance x of a prolem, the method works as follows: divide-and-conquer
More informationLecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018
CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of
More informationCS 2110: INDUCTION DISCUSSION TOPICS
CS 110: INDUCTION DISCUSSION TOPICS The following ideas are suggestions for how to handle your discussion classes. You can do as much or as little of this as you want. You can either present at the board,
More informationChapter 1. Comparison-Sorting and Selecting in. Totally Monotone Matrices. totally monotone matrices can be found in [4], [5], [9],
Chapter 1 Comparison-Sorting and Selecting in Totally Monotone Matrices Noga Alon Yossi Azar y Abstract An mn matrix A is called totally monotone if for all i 1 < i 2 and j 1 < j 2, A[i 1; j 1] > A[i 1;
More informationDivide and Conquer Algorithms
Divide and Conquer Algorithms Introduction There exist many problems that can be solved using a divide-and-conquer algorithm. A divide-andconquer algorithm A follows these general guidelines. Divide Algorithm
More informationStrategies for Stable Merge Sorting
Strategies for Stable Merge Sorting Sam Buss Alexander Knop Abstract We introduce new stable natural merge sort algorithms, called -merge sort and -merge sort. We prove upper and lower bounds for several
More informationCS313H Logic, Sets, and Functions: Honors Fall 2012
CS313H Logic, Sets, and Functions: Honors Fall 2012 Prof: TA: Jacob Schrum Proctor: Sudheesh Katkam Department of Computer Science The University of Texas at Austin Good Morning, Colleagues Good Morning,
More informationExercises - Solutions
Chapter 1 Exercises - Solutions Exercise 1.1. The first two definitions are equivalent, since we follow in both cases the unique path leading from v to a sink and using only a i -edges leaving x i -nodes.
More informationCS325: Analysis of Algorithms, Fall Midterm
CS325: Analysis of Algorithms, Fall 2017 Midterm I don t know policy: you may write I don t know and nothing else to answer a question and receive 25 percent of the total points for that problem whereas
More informationDivide and conquer. Philip II of Macedon
Divide and conquer Philip II of Macedon Divide and conquer 1) Divide your problem into subproblems 2) Solve the subproblems recursively, that is, run the same algorithm on the subproblems (when the subproblems
More informationAll of the above algorithms are such that the total work done by themisω(n 2 m 2 ). (The work done by a parallel algorithm that uses p processors and
Efficient Parallel Algorithms for Template Matching Sanguthevar Rajasekaran Department of CISE, University of Florida Abstract. The parallel complexity of template matching has been well studied. In this
More informationParallel Prefix Algorithms 1. A Secret to turning serial into parallel
Parallel Prefix Algorithms. A Secret to turning serial into parallel 2. Suppose you bump into a parallel algorithm that surprises you there is no way to parallelize this algorithm you say 3. Probably a
More informationDivide and Conquer Algorithms
Divide and Conquer Algorithms T. M. Murali February 19, 2013 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine
More informationFundamental Algorithms
Chapter 2: Sorting, Winter 2018/19 1 Fundamental Algorithms Chapter 2: Sorting Jan Křetínský Winter 2018/19 Chapter 2: Sorting, Winter 2018/19 2 Part I Simple Sorts Chapter 2: Sorting, Winter 2018/19 3
More informationFundamental Algorithms
Fundamental Algorithms Chapter 2: Sorting Harald Räcke Winter 2015/16 Chapter 2: Sorting, Winter 2015/16 1 Part I Simple Sorts Chapter 2: Sorting, Winter 2015/16 2 The Sorting Problem Definition Sorting
More informationDivide and Conquer CPE 349. Theresa Migler-VonDollen
Divide and Conquer CPE 349 Theresa Migler-VonDollen Divide and Conquer Divide and Conquer is a strategy that solves a problem by: 1 Breaking the problem into subproblems that are themselves smaller instances
More informationDesign and Analysis of Algorithms
CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 4: Divide and Conquer (I) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Divide and Conquer ( DQ ) First paradigm or framework DQ(S)
More informationLecture 22: Multithreaded Algorithms CSCI Algorithms I. Andrew Rosenberg
Lecture 22: Multithreaded Algorithms CSCI 700 - Algorithms I Andrew Rosenberg Last Time Open Addressing Hashing Today Multithreading Two Styles of Threading Shared Memory Every thread can access the same
More informationRandomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th
CSE 3500 Algorithms and Complexity Fall 2016 Lecture 10: September 29, 2016 Quick sort: Average Run Time In the last lecture we started analyzing the expected run time of quick sort. Let X = k 1, k 2,...,
More informationT U M I N S T I T U T F Ü R I N F O R M A T I K. Optimal Parallel Algorithms for Two Processor Scheduling with Tree Precedence Constraints
T U M I N S T I T U T F Ü R I N F O R M A T I K Optimal Parallel Algorithms for Two Processor Scheduling with Tree Precedence Constraints Ernst W. Mayr Hans Stadtherr? TUM-I9531 November 1995 T E C H N
More informationDivide-and-Conquer and Recurrence Relations: Notes on Chapter 2, Dasgupta et.al. Howard A. Blair
Divide-and-Conquer and Recurrence Relations: Notes on Chapter 2, Dasgupta et.al. Howard A. Blair 1 Multiplication Example 1.1: Carl Friedrich Gauss (1777-1855): The multiplication of two complex numbers
More informationSingle Source Shortest Paths
CMPS 00 Fall 017 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight
More informationCMPS 2200 Fall Divide-and-Conquer. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk
CMPS 2200 Fall 2017 Divide-and-Conquer Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 The divide-and-conquer design paradigm 1. Divide the problem (instance)
More informationA point p is said to be dominated by point q if p.x=q.x&p.y=q.y 2 true. In RAM computation model, RAM stands for Random Access Model.
In analysis the upper bound means the function grows asymptotically no faster than its largest term. 1 true A point p is said to be dominated by point q if p.x=q.x&p.y=q.y 2 true In RAM computation model,
More informationData structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:
Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O
More informationCS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms
CS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions
More information1 Caveats of Parallel Algorithms
CME 323: Distriuted Algorithms and Optimization, Spring 2015 http://stanford.edu/ reza/dao. Instructor: Reza Zadeh, Matroid and Stanford. Lecture 1, 9/26/2015. Scried y Suhas Suresha, Pin Pin, Andreas
More informationHamiltonian paths in tournaments A generalization of sorting DM19 notes fall 2006
Hamiltonian paths in tournaments A generalization of sorting DM9 notes fall 2006 Jørgen Bang-Jensen Imada, SDU 30. august 2006 Introduction and motivation Tournaments which we will define mathematically
More informationWhen we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:
CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe
More informationDivide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14
Divide and Conquer Algorithms CSE 101: Design and Analysis of Algorithms Lecture 14 CSE 101: Design and analysis of algorithms Divide and conquer algorithms Reading: Sections 2.3 and 2.4 Homework 6 will
More informationGrade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2
1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 5 Recurrences, Part 2 Running time of algorithms In computer science,
More informationOutline. Part 5. Computa0onal Complexity (3) Compound Interest 2/15/12. Recurrence Rela0ons: An Overview. Recurrence Rela0ons: Formal Defini0on
Outline Part 5. Computa0onal Complexity (3) Recurrence Relations Divide and Conquer Understanding the Complexity of Algorithms CS 200 Algorithms and Data Structures 1 2 Recurrence Rela0ons: An Overview
More informationInf 2B: Sorting, MergeSort and Divide-and-Conquer
Inf 2B: Sorting, MergeSort and Divide-and-Conquer Lecture 7 of ADS thread Kyriakos Kalorkoti School of Informatics University of Edinburgh The Sorting Problem Input: Task: Array A of items with comparable
More informationDivide and Conquer algorithms
Divide and Conquer algorithms Another general method for constructing algorithms is given by the Divide and Conquer strategy. We assume that we have a problem with input that can be split into parts in
More informationDivide-and-Conquer Algorithms Part Two
Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller
More informationDivide and Conquer Strategy
Divide and Conquer Strategy Algorithm design is more an art, less so a science. There are a few useful strategies, but no guarantee to succeed. We will discuss: Divide and Conquer, Greedy, Dynamic Programming.
More informationData Structures and Algorithm Analysis (CSC317) Randomized Algorithms (part 3)
Data Structures and Algorithm Analysis (CSC317) Randomized Algorithms (part 3) Quicksort p r Quicksort(A, p, r) 1. If p
More information1. (a) Explain the asymptotic notations used in algorithm analysis. (b) Prove that f(n)=0(h(n)) where f(n)=0(g(n)) and g(n)=0(h(n)).
Code No: R05220502 Set No. 1 1. (a) Explain the asymptotic notations used in algorithm analysis. (b) Prove that f(n)=0(h(n)) where f(n)=0(g(n)) and g(n)=0(h(n)). 2. (a) List some of the relative advantages
More informationDerivation of Parallel Sorting Algorithms
in Parallel Algorithm Derivation and Program Transformation, Eds. R. Paige, J. Reif, and R. Wachter, Kluwer Academic Publishers, Boston, 1993, pages 55 69. Derivation of Parallel Sorting Algorithms Douglas
More informationOutline. 1 Merging. 2 Merge Sort. 3 Complexity of Sorting. 4 Merge Sort and Other Sorts 2 / 10
Merge Sort 1 / 10 Outline 1 Merging 2 Merge Sort 3 Complexity of Sorting 4 Merge Sort and Other Sorts 2 / 10 Merging Merge sort is based on a simple operation known as merging: combining two ordered arrays
More informationDivide and Conquer. Andreas Klappenecker. [based on slides by Prof. Welch]
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch] Divide and Conquer Paradigm An important general technique for designing algorithms: divide problem into subproblems recursively
More informationSolving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.
Solving Recurrences Recurrences and Recursive Code Many (perhaps most) recursive algorithms fall into one of two categories: tail recursion and divide-andconquer recursion. We would like to develop some
More informationInsertion Sort. We take the first element: 34 is sorted
Insertion Sort Idea: by Ex Given the following sequence to be sorted 34 8 64 51 32 21 When the elements 1, p are sorted, then the next element, p+1 is inserted within these to the right place after some
More information