Plan. Analysis of Multithreaded Algorithms. Plan. Matrix multiplication. University of Western Ontario, London, Ontario (Canada) Marc Moreno Maza
|
|
- Brook Newman
- 6 years ago
- Views:
Transcription
1 Pla Aalysis of Multithreaded Algorithms Marc Moreo Maza Uiversity of Wester Otario, Lodo, Otario (Caada) CS Pla (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Matrix multiplicatio c 11 c 12 c 1 c 21 c 22 c 2 a 11 a 12 a 1 a 21 a 22 a 2 = b 11 b 12 b 1 b 21 b 22 b 2 c 1 c 2 c a 1 a 2 a b 1 b 2 b C A B We will study three approaches: a aive ad iterative oe a divide-ad-coquer oe a divide-ad-coquer oe with memory maagemet cosideratio (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
2 Naive iterative matrix multiplicatio Naive iterative matrix multiplicatio cilk_for (it i=1; i<; ++i) { cilk_for (it j=0; j<; ++j) { for (it k=0; k<; ++k { C[i][j] += A[i][k] * B[k][j]; Work:? Spa:? Parallelism:? cilk_for (it i=1; i<; ++i) { cilk_for (it j=0; j<; ++j) { for (it k=0; k<; ++k { C[i][j] += A[i][k] * B[k][j]; Work: Θ( 3 ) Spa: Θ() Parallelism: Θ( 2 ) (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Matrix multiplicatio based o block decompositio (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Divide-ad-coquer matrix multiplicatio C 11 C 12 A 11 A 12 B 11 B 12 = C 21 C 22 A 21 A 22 B 21 B 22 A 11 B 11 A 11 B 12 A 12 B 21 A 12 B 22 = + A 21 B 11 A 21 B 12 A 22 B 21 A 22 B The divide-ad-coquer approach is simply the oe based o blockig, preseted i the first lecture. (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 // C <- C + A * B void MMult(T *C, T *A, T *B, it, it size) { T *D = ew T[*]; //base case & partitio matrices cilk_spaw MMult(C11, A11, B11, /2, size); cilk_spaw MMult(C12, A11, B12, /2, size); cilk_spaw MMult(C22, A21, B12, /2, size); cilk_spaw MMult(C21, A21, B11, /2, size); cilk_spaw MMult(D11, A12, B21, /2, size); cilk_spaw MMult(D12, A12, B22, /2, size); cilk_spaw MMult(D22, A22, B22, /2, size); MMult(D21, A22, B21, /2, size); MAdd(C, D,, size); // C += D; delete[] D; Work? Spa? Parallelism? (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
3 Divide-ad-coquer matrix multiplicatio Divide-ad-coquer matrix multiplicatio: No temporaries! void MMult(T *C, T *A, T *B, it, it size) { T *D = ew T[*]; //base case & partitio matrices cilk_spaw MMult(C11, A11, B11, /2, size); cilk_spaw MMult(C12, A11, B12, /2, size); cilk_spaw MMult(C22, A21, B12, /2, size); cilk_spaw MMult(C21, A21, B11, /2, size); cilk_spaw MMult(D11, A12, B21, /2, size); cilk_spaw MMult(D12, A12, B22, /2, size); cilk_spaw MMult(D22, A22, B22, /2, size); MMult(D21, A22, B21, /2, size); MAdd(C, D,, size); // C += D; delete[] D; A p () ad M p (): times o p proc. for Add ad Mult. A 1 () = 4A 1 (/2) + Θ(1) = Θ( 2 ) A () = A (/2) + Θ(1) = Θ(lg ) M 1 () = 8M 1 (/2) + A 1 () = 8M 1 (/2) + Θ( 2 ) = Θ( 3 ) M () = M (/2) + Θ(lg ) = Θ(lg 2 ) M 1 ()/M () = Θ( 3 / lg 2 ) (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Divide-ad-coquer matrix multiplicatio: No temporaries! void MMult2(T *C, T *A, T *B, it, it size) { //base case & partitio matrices cilk_spaw MMult2(C11, A11, B11, /2, size); cilk_spaw MMult2(C12, A11, B12, /2, size); cilk_spaw MMult2(C22, A21, B12, /2, size); MMult2(C21, A21, B11, /2, size); cilk_spaw MMult2(C11, A12, B21, /2, size); cilk_spaw MMult2(C12, A12, B22, /2, size); cilk_spaw MMult2(C22, A22, B22, /2, size); MMult2(C21, A22, B21, /2, size); Work? Spa? Parallelism? Pla (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 void MMult2(T *C, T *A, T *B, it, it size) { //base case & partitio matrices cilk_spaw MMult2(C11, A11, B11, /2, size); cilk_spaw MMult2(C12, A11, B12, /2, size); cilk_spaw MMult2(C22, A21, B12, /2, size); MMult2(C21, A21, B11, /2, size); cilk_spaw MMult2(C11, A12, B21, /2, size); cilk_spaw MMult2(C12, A12, B22, /2, size); cilk_spaw MMult2(C22, A22, B22, /2, size); MMult2(C21, A22, B21, /2, size); MA p (): time o p proc. for Mult-Add. MA 1 () = Θ( 3 ) MA () = 2MA (/2) + Θ(1) = Θ() MA 1 ()/MA () = Θ( 2 ) Besides, savig space ofte saves time due to hierarchical memory. (Moreo Maza) Aalysis of Multithreaded Algorithms CS / (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
4 Mergig two sorted arrays Merge sort void Merge(T *C, T *A, T *B, it a, it b) { while (a>0 && b>0) { if (*A <= *B) { *C++ = *A++; a--; else { *C++ = *B++; b--; while (a>0) { *C++ = *A++; a--; while (b>0) { *C++ = *B++; b--; Time for mergig elemets is Θ(). merge merge merge (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Parallel merge sort with serial merge (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Parallel merge sort with serial merge void MergeSort(T *B, T *A, it ) { if (==1) { else { T* C[]; cilk_spaw MergeSort(C, A, /2); MergeSort(C+/2, A+/2, -/2); Merge(B, C, C+/2, /2, -/2); Work? Spa? void MergeSort(T *B, T *A, it ) { if (==1) { else { T* C[]; cilk_spaw MergeSort(C, A, /2); MergeSort(C+/2, A+/2, -/2); Merge(B, C, C+/2, /2, -/2); T 1 () = 2T 1 (/2) + Θ() thus T 1 () == Θ( lg ). T () = T (/2) + Θ() thus T () = Θ(). T 1 ()/T () = Θ(lg ). Puy parallelism! We eed to parallelize the merge! (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
5 Parallel merge Parallel merge A Recursive P_Merge B 0 ma = a/2 a A[ma] A[ma] Biary Search A[ma] A[ma] Recursive P_Merge 0 mb-1 mb b a b Idea: if the total umber of elemets to be sorted i = a + b the the maximum umber of elemets i ay of the two merges is at most 3/4. (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Parallel merge void P_Merge(T *C, T *A, T *B, it a, it b) { if (a < b) { P_Merge(C, B, A, b, a); else if (a==0) { retur; else { it ma = a/2; it mb = BiarySearch(A[ma], B, b); C[ma+mb] = A[ma]; cilk_spaw P_Merge(C, A, B, ma, mb); P_Merge(C+ma+mb+1, A+ma+1, B+mb, a-ma-1, b-mb); Oe should coarse the base case for efficiecy. Work? Spa? (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Aalyzig parallel merge void P_Merge(T *C, T *A, T *B, it a, it b) { if (a < b) { P_Merge(C, B, A, b, a); else if (a==0) { retur; else { it ma = a/2; it mb = BiarySearch(A[ma], B, b); C[ma+mb] = A[ma]; cilk_spaw P_Merge(C, A, B, ma, mb); P_Merge(C+ma+mb+1, A+ma+1, B+mb, a-ma-1, b-mb); Let PM p () be the p-processor ruig time of P-Merge. I the worst case, the spa of P-Merge is PM () PM (3/4) + Θ(lg ) = Θ(lg 2 ) The worst-case work of P-Merge satisfies the recurrece PM 1 () PM 1 (α) + PM 1 ((1 α)) + Θ(lg ) (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Recall PM 1 () PM 1 (α) + PM 1 ((1 α)) + Θ(lg ) for some 1/4 α 3/4. To solve this hairy equatio we use the substitutio method. We assume there exist some costats a, b > 0 such that PM 1 () a b lg holds for all 1/4 α 3/4. After substitutio, this hypothesis implies: PM 1 () a b lg b lg + Θ(lg ). We ca pick b large eough such that we have PM 1 () a b lg for all 1/4 α 3/4 ad all > 1/ The pick a large eough to satisfy the base coditios. Fially we have PM 1 () = Θ(). (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
6 Parallel merge sort with parallel merge Parallel merge sort with parallel merge void P_MergeSort(T *B, T *A, it ) { if (==1) { else { T C[]; cilk_spaw P_MergeSort(C, A, /2); P_MergeSort(C+/2, A+/2, -/2); P_Merge(B, C, C+/2, /2, -/2); Pla Work? Spa? (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 void P_MergeSort(T *B, T *A, it ) { if (==1) { else { T C[]; cilk_spaw P_MergeSort(C, A, /2); P_MergeSort(C+/2, A+/2, -/2); P_Merge(B, C, C+/2, /2, -/2); The work satisfies T 1 () = 2T 1 (/2) + Θ() (as usual) ad we have T 1 () = Θ(log()). The worst case critical-path legth of the Merge-Sort ow satisfies T () = T (/2) + Θ(lg 2 ) = Θ(lg 3 ). The parallelism is ow Θ( lg )/Θ(lg 3 ) = Θ(/ lg 2 ). (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Tableau costructio Costructig a tableau A satisfyig a relatio of the form: The work is Θ( 2 ). A[i, j] = R(A[i 1, j], A[i 1, j 1], A[i, j 1]). (1) (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
7 Recursive costructio A more parallel costructio I III II IV Parallel code I; cilk_spaw II; III; IV; I II IV III V VII VI VIII IX I; cilk_spaw II; III; cilk_spaw IV; cilk_spaw V; VI; cilk_spaw VII; VIII; IX; T 1 () = 4T 1 (/2) + Θ(1), thus T 1 () = Θ( 2 ). T () = 3T (/2) + Θ(1), thus T () = Θ( log 2 3 ). Parallelism: Θ( 2 log 2 3 ) = Ω( 0.41 ). (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Ackowledgemets T 1 () = 9T 1 (/3) + Θ(1), thus T 1 () = Θ( 2 ). T () = 5T (/3) + Θ(1), thus T () = Θ( log 3 5 ). Parallelism: Θ( 2 log 3 5 ) = Ω( 0.53 ). This ie-way d--c has more parallelism tha the four way but exhibits more cache complexity (more o this later). (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27 Charles E. Leiserso (MIT) for providig me with the sources of its lecture otes. Matteo Frigo (Itel) for supportig the work of my team with Cilk++ ad offerig us the ext lecture. Yuzhe Xie (UWO) for helpig me with the images used i these slides. Liyu Li (UWO) for geeratig the experimetal data. (Moreo Maza) Aalysis of Multithreaded Algorithms CS / 27
Analysis of Multithreaded Algorithms
Analysis of Multithreaded Algorithms Marc Moreno Maza University of Western Ontario, London, Ontario (Canada) CS 4435 - CS 9624 (Moreno Maza) Analysis of Multithreaded Algorithms CS 4435 - CS 9624 1 /
More informationCS 240A : Examples with Cilk++
CS 240A : Examples with Cilk++ Divide & Conquer Paradigm for Cilk++ Solving recurrences Sorting: Quicksort and Mergesort Graph traversal: Breadth-First Search Thanks to Charles E. Leiserson for some of
More informationCache-Efficient Algorithms II
6.172 Performace Egieerig of Software Systems LECTURE 9 Cache-Efficiet Algorithms II Charles E. Leiserso October 7, 2010 2010 Charles E. Leiserso 1 Ideal-Cache Model Features Two-level hierarchy. Cache
More informationIntroduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication
Itroductio to Algorithms 6.046J/8.40J LECTURE 3 Divide ad coquer Biary search Powerig a umber Fiboacci umbers Matrix multiplicatio Strasse s algorithm VLSI tree layout Prof. Charles E. Leiserso The divide-ad-coquer
More informationA recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.
CS23 Algorithms Hadout #6 Prof Ly Turbak September 8, 200 Wellesley College RECURRENCES This hadout summarizes highlights of CLRS Chapter 4 ad Appedix A (CLR Chapters 3 & 4) Two-Step Strategy for Aalyzig
More informationAlgorithms and Data Structures Lecture IV
Algorithms ad Data Structures Lecture IV Simoas Šalteis Aalborg Uiversity simas@cs.auc.dk September 5, 00 1 This Lecture Aalyzig the ruig time of recursive algorithms (such as divide-ad-coquer) Writig
More informationCS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides
CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis
More informationThis Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2
This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is
More informationDesign and Analysis of Algorithms
Desig ad Aalysis of Algorithms CSE 53 Lecture 9 Media ad Order Statistics Juzhou Huag, Ph.D. Departmet of Computer Sciece ad Egieerig Dept. CSE, UT Arligto CSE53 Desig ad Aalysis of Algorithms Medias ad
More informationAlgorithms 演算法. Multi-threaded Algorithms
演算法 Multi-threaded Professor Chie-Mo James Li 李建模 Graduate Istitute of Electroics Egieerig Natioal aiwa Uiversity Outlie Multithreaded, CH7 7. Basics 7. Matrix Multiplicatio 7.3 Merge sort Leoardo Fiboacci
More informationCS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)
1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,
More informationRecurrence Relations
Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The
More informationData Structures Lecture 9
Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to
More informationCSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions
CSE 09/09 Topics i ig Data Aalytics Sprig 2017; Homework 1 Solutios Note: Solutios to problems,, ad 6 are due to Marius Nicolae. 1. Cosider the followig algorithm: for i := 1 to α log e do Pick a radom
More informationData Structures and Algorithm. Xiaoqing Zheng
Data Structures ad Algorithm Xiaoqig Zheg zhegxq@fudaeduc What are algorithms? A sequece of computatioal steps that trasform the iput ito the output Sortig problem: Iput: A sequece of umbers
More informationAlgorithms Design & Analysis. Divide & Conquer
Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised
More informationSorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.
Sortig Algorithms Algorithms Kyuseo Shim SoEECS, SNU. Desigig Algorithms Icremetal approaches Divide-ad-Coquer approaches Dyamic programmig approaches Greedy approaches Radomized approaches You are ot
More informationCS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2
Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.
More informationCS 332: Algorithms. Quicksort
CS 33: Aorithms Quicsort David Luebe //03 Homewor Assiged today, due ext Wedesday Will be o web page shortly after class Go over ow David Luebe //03 Review: Quicsort Sorts i place Sorts O( ) i the average
More informationDivide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.
Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem
More informationData Structures and Algorithms
Data Structures ad Algorithms Autum 2017-2018 Outlie 1 Sortig Algorithms (cotd) Outlie Sortig Algorithms (cotd) 1 Sortig Algorithms (cotd) Heapsort Sortig Algorithms (cotd) Have see that we ca build a
More informationAverage-Case Analysis of QuickSort
Average-Case Aalysis of QuickSort Comp 363 Fall Semester 003 October 3, 003 The purpose of this documet is to itroduce the idea of usig recurrece relatios to do average-case aalysis. The average-case ruig
More informationRecursive Algorithm for Generating Partitions of an Integer. 1 Preliminary
Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the
More informationTest One (Answer Key)
CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)
More informationCSE 613: Parallel Programming. Lecture 8 ( Analyzing Divide-and-Conquer Algorithms )
CSE 613: Parallel Programming Lecture 8 ( Analyzing Divide-and-Conquer Algorithms ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2012 A Useful Recurrence Consider the following
More informationMathematical Foundation. CSE 6331 Algorithms Steve Lai
Mathematical Foudatio CSE 6331 Algorithms Steve Lai Complexity of Algorithms Aalysis of algorithm: to predict the ruig time required by a algorithm. Elemetary operatios: arithmetic & boolea operatios:
More informationITEC 360 Data Structures and Analysis of Algorithms Spring for n 1
ITEC 360 Data Structures ad Aalysis of Algorithms Sprig 006 1. Prove that f () = 60 + 5 + 1 is Θ ( ). 60 + 5 + 1 60 + 5 + = 66 for 1 Take C 1 = 66 f () = 60 + 5 + 1 is O( ) Sice 60 + 5 + 1 60 for 1 If
More informationAlgorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources
Algorithm Aalysis Algorithms that are equally correct ca vary i their utilizatio of computatioal resources time ad memory a slow program it is likely ot to be used a program that demads too much memory
More informationCS / MCS 401 Homework 3 grader solutions
CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of
More informationCOMP285 Midterm Exam Department of Mathematics
COMP85 Midterm Exam Departmet of Mathematics Fall 010/011 - November 8, 010 Name: Studet Number: Please fiish withi 90 miutes. All poits above 100 are cosidered as bous poit. You ca reach maximal 1 poits.
More informationRecursive Algorithms. Recurrences. Recursive Algorithms Analysis
Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects
More informationAnalysis of Algorithms -Quicksort-
Aalysis of Algorithms -- Adreas Ermedahl MRTC (Mälardales Real-Time Research Ceter) adreas.ermedahl@mdh.se Autum 2004 Proposed by C.A.R. Hoare i 962 Worst- case ruig time: Θ( 2 ) Expected ruig time: Θ(
More informationCS161 Design and Analysis of Algorithms. Administrative
CS161 Desig ad Aalysis of Algorithms Da Boeh 1 Admiistrative Lecture 1, April 3, 1 Web page http://theory.staford.edu/~dabo/cs161» Hadouts» Aoucemets» Late breakig ews Gradig ad course requiremets» Midterm/fial/hw»
More informationMerge and Quick Sort
Merge ad Quick Sort Merge Sort Merge Sort Tree Implemetatio Quick Sort Pivot Item Radomized Quick Sort Adapted from: Goodrich ad Tamassia, Data Structures ad Algorithms i Java, Joh Wiley & So (1998). Ruig
More informationDepartment of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:
Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch Iformatik II Midterm1 Sprig 018 3.03.018 Advice You have 90 miutes to complete
More informationClassification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)
Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:
More informationCSE 332. Data Structures and Parallelism
Aam Blak Lecture 6a Witer 2017 CSE 332 Data Structures a Parallelism CSE 332: Data Structures a Parallelism More Recurreces T () T (/2) T (/2) T (/4) T (/4) T (/4) T (/4) P1 De-Brief 1 You i somethig substatial!
More informationCS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2
Shiyao Wag CS:3330 (Prof. Pemmaraju ): Assigmet #1 Solutios Problem 1 (a) Cosider iput with me m 1, m,..., m ad wome w 1, w,..., w with the followig prefereces: All me have the same prefereces for wome:
More informationDivide and Conquer II
Algorithms Divide ad Coquer II Divide ad Coquer II Desig ad Aalsis of Algorithms Adrei Bulatov Algorithms Divide ad Coquer II 6- Closest Pair: The Problem The Closest Pair Problem Istace: poits i the plae
More informationMatriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:
Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch AlgoDat Midterm1 Sprig 016 08.04.016 Name: Matriculatio umber: Advice You have
More informationCSE 613: Parallel Programming. Lectures ( Analyzing Divide-and-Conquer Algorithms )
CSE 613: Parallel Programming Lectures 13 14 ( Analyzing Divide-and-Conquer Algorithms ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2015 A Useful Recurrence Consider the
More informationCS 5150/6150: Assignment 1 Due: Sep 23, 2010
CS 5150/6150: Assigmet 1 Due: Sep 23, 2010 Wei Liu September 24, 2010 Q1: (1) Usig master theorem: a = 7, b = 4, f() = O(). Because f() = log b a ε holds whe ε = log b a = log 4 7, we ca apply the first
More information4.3 Growth Rates of Solutions to Recurrences
4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.
More informationAnalysis of Algorithms. Introduction. Contents
Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We
More informationChapter 22 Developing Efficient Algorithms
Chapter Developig Efficiet Algorithms 1 Executig Time Suppose two algorithms perform the same task such as search (liear search vs. biary search). Which oe is better? Oe possible approach to aswer this
More informationModel of Computation and Runtime Analysis
Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map
More informationSimilar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication
Next. Covered bsics of simple desig techique (Divided-coquer) Ch. of the text.. Next, Strsse s lgorithm. Lter: more desig d coquer lgorithms: MergeSort. Solvig recurreces d the Mster Theorem. Similr ide
More informationCO Algorithms: Brief History
Piyush Kumar Departmet of Computer Sciece Advisor: Joseph S.B. Mitchell CO Algorithms: Brief History Frigo, Leiserso, Prokop, Ramachadra (FOCS 99) Cache Oblivious Algorithms Thesis Harold Prokop s Thesis
More informationAlgorithms. Elementary Sorting. Dong Kyue Kim Hanyang University
Algorithms Elemetary Sortig Dog Kyue Kim Hayag Uiversity dqkim@hayag.a.kr Cotets Sortig problem Elemetary sortig algorithms Isertio sort Merge sort Seletio sort Bubble sort Sortig problem Iput A sequee
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 informationChapter 2. Asymptotic Notation
Asyptotic Notatio 3 Chapter Asyptotic Notatio Goal : To siplify the aalysis of ruig tie by gettig rid of details which ay be affected by specific ipleetatio ad hardware. [1] The Big Oh (O-Notatio) : It
More informationCSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)
CSI 101 Discrete Structures Witer 01 Prof. Lucia Moura Uiversity of Ottawa Homework Assigmet #4 (100 poits, weight %) Due: Thursday, April, at 1:00pm (i lecture) Program verificatio, Recurrece Relatios
More information1 Hash tables. 1.1 Implementation
Lecture 8 Hash Tables, Uiversal Hash Fuctios, Balls ad Bis Scribes: Luke Johsto, Moses Charikar, G. Valiat Date: Oct 18, 2017 Adapted From Virgiia Williams lecture otes 1 Hash tables A hash table is a
More informationCIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5
CIS 11 Data Structures ad Algorithms with Java Sprig 019 Code Sippets ad Recurreces Moday, February 4/Tuesday, February 5 Learig Goals Practice provig asymptotic bouds with code sippets Practice solvig
More informationSequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018
CSE 353 Discrete Computatioal Structures Sprig 08 Sequeces, Mathematical Iductio, ad Recursio (Chapter 5, Epp) Note: some course slides adopted from publisher-provided material Overview May mathematical
More informationCOMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro
COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T.
More informationIntroduction to Algorithms
Itroductio to Algorithms 6.046J/8.40J LECTURE 9 Radomly built biary search trees Epected ode depth Aalyzig height Coveity lemma Jese s iequality Epoetial height Post mortem Pro. Eri Demaie October 7, 2005
More informationIntroduction to Algorithms
Itroductio to Algorithms 6.046J/8.40J/SMA5503 Lecture 9 Pro. Charles E. Leiserso Biary-search-tree sort T Create a empty BST or i to do TREE-INSERT(T, A[i]) Perorm a iorder tree wal o T. Eample: A [3 8
More informationMath 475, Problem Set #12: Answers
Math 475, Problem Set #12: Aswers A. Chapter 8, problem 12, parts (b) ad (d). (b) S # (, 2) = 2 2, sice, from amog the 2 ways of puttig elemets ito 2 distiguishable boxes, exactly 2 of them result i oe
More information) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È
Algorithms Professor Joh Reif ALG 1.3 Determiistic Selectio ad Sortig: (a) Selectio Algorithms ad Lower Bouds (b) Sortig Algorithms ad Lower Bouds Problem P size fi divide ito subproblems size 1,..., k
More informationFundamental Algorithms
Fudametal Algorithms Chapter 2b: Recurreces Michael Bader Witer 2014/15 Chapter 2b: Recurreces, Witer 2014/15 1 Recurreces Defiitio A recurrece is a (i-equality that defies (or characterizes a fuctio i
More informationCSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN
CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.5703) ALGORITHM ANALYSIS AND DESIGN (3 cr.) (T) Topics of curret iterest i the desig ad aalysis of computer algorithms for graphtheoretical
More informationModel of Computation and Runtime Analysis
Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map
More informationPolynomial Multiplication and Fast Fourier Transform
Polyomial Multiplicatio ad Fast Fourier Trasform Com S 477/577 Notes Ya-Bi Jia Sep 19, 2017 I this lecture we will describe the famous algorithm of fast Fourier trasform FFT, which has revolutioized digital
More informationSums, products and sequences
Sums, products ad sequeces How to write log sums, e.g., 1+2+ (-1)+ cocisely? i=1 Sum otatio ( sum from 1 to ): i 3 = 1 + 2 + + If =3, i=1 i = 1+2+3=6. The ame ii does ot matter. Could use aother letter
More informationCS284A: Representations and Algorithms in Molecular Biology
CS284A: Represetatios ad Algorithms i Molecular Biology Scribe Notes o Lectures 3 & 4: Motif Discovery via Eumeratio & Motif Represetatio Usig Positio Weight Matrix Joshua Gervi Based o presetatios by
More informationHashing. Algorithm : Design & Analysis [09]
Hashig Algorithm : Desig & Aalysis [09] I the last class Implemetig Dictioary ADT Defiitio of red-black tree Black height Isertio ito a red-black tree Deletio from a red-black tree Hashig Hashig Collisio
More information-ORDER CONVERGENCE FOR FINDING SIMPLE ROOT OF A POLYNOMIAL EQUATION
NEW NEWTON-TYPE METHOD WITH k -ORDER CONVERGENCE FOR FINDING SIMPLE ROOT OF A POLYNOMIAL EQUATION R. Thukral Padé Research Cetre, 39 Deaswood Hill, Leeds West Yorkshire, LS7 JS, ENGLAND ABSTRACT The objective
More informationLet A(x) and B(x) be two polynomials of degree n 1:
MI-EVY (2011/2012) J. Holub: 4. DFT, FFT ad Patter Matchig p. 2/42 Operatios o polyomials MI-EVY (2011/2012) J. Holub: 4. DFT, FFT ad Patter Matchig p. 4/42 Efficiet Patter Matchig (MI-EVY) 4. DFT, FFT
More informationCSE 5311 Notes 1: Mathematical Preliminaries
Chapter 1 - Algorithms Computig CSE 5311 Notes 1: Mathematical Prelimiaries Last updated 1/20/18 12:56 PM) Relatioship betwee complexity classes, eg log,, log, 2, 2, etc Chapter 2 - Gettig Started Loop
More informationCSE Introduction to Parallel Processing. Chapter 3. Parallel Algorithm Complexity
Dr. Izadi CSE-40533 Itroductio to Parallel Processig Chapter 3 Parallel Algorithm Complexity Review algorithm complexity ad various complexity classes Itroduce the otios of time ad time-cost optimality
More informationParallel Vector Algorithms David A. Padua
Parallel Vector Algorithms 1 of 32 Itroductio Next, we study several algorithms where parallelism ca be easily expressed i terms of array operatios. We will use Fortra 90 to represet these algorithms.
More informationDivide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016
COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Lecturer: Debmalya Paigrahi Divide ad Coquer Scribe: Tiaqi Sog 1 Overview I this lecture, a importat algorithm desig techique called divide-ad-coquer
More information+ au n+1 + bu n = 0.)
Lecture 6 Recurreces - kth order: u +k + a u +k +... a k u k 0 where a... a k are give costats, u 0... u k are startig coditios. (Simple case: u + au + + bu 0.) How to solve explicitly - first, write characteristic
More informationCSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability.
CSE 0 Homework 1 Matthias Spriger, A9950078 1 Problem 1 Notatio a b meas that a is matched to b. a < b c meas that b likes c more tha a. Equality idicates a tie. Strog istability Yes, there does always
More informationCOS 341 Discrete Mathematics. Exponential Generating Functions and Recurrence Relations
COS 341 Discrete Mathematics Epoetial Geeratig Fuctios ad Recurrece Relatios 1 Tetbook? 1 studets said they eeded the tetbook, but oly oe studet bought the tet from Triagle. If you do t have the book,
More informationExamples: data compression, path-finding, game-playing, scheduling, bin packing
Algorithms - Basic Cocepts Algorithms so what is a algorithm, ayway? The dictioary defiitio: A algorithm is a well-defied computatioal procedure that takes iput ad produces output. This class will deal
More informationsubcaptionfont+=small,labelformat=parens,labelsep=space,skip=6pt,list=0,hypcap=0 subcaption ALGEBRAIC COMBINATORICS LECTURE 8 TUESDAY, 2/16/2016
subcaptiofot+=small,labelformat=pares,labelsep=space,skip=6pt,list=0,hypcap=0 subcaptio ALGEBRAIC COMBINATORICS LECTURE 8 TUESDAY, /6/06. Self-cojugate Partitios Recall that, give a partitio λ, we may
More informationAdvanced Course of Algorithm Design and Analysis
Differet complexity measures Advaced Course of Algorithm Desig ad Aalysis Asymptotic complexity Big-Oh otatio Properties of O otatio Aalysis of simple algorithms A algorithm may may have differet executio
More information2. ALGORITHM ANALYSIS
2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times 2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times Lecture slides by Kevi Waye Copyright 2005 Pearso-Addiso
More informationCOMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro
COMP60: Itroduig Complexity Aalysis (08/9) Luas Cordeiro luas.ordeiro@mahester.a.uk Itroduig Complexity Aalysis Textbook: Algorithm Desig ad Appliatios, Goodrih, Mihael T. ad Roberto Tamassia (hapter )
More informationAppendix: The Laplace Transform
Appedix: The Laplace Trasform The Laplace trasform is a powerful method that ca be used to solve differetial equatio, ad other mathematical problems. Its stregth lies i the fact that it allows the trasformatio
More informationLecture 3: Asymptotic Analysis + Recurrences
Lecture 3: Asymptotic Aalysis + Recurreces Data Structures ad Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Write a model ad fid Big-O for (it i = 0; i < ; i++) { for (it j = 0; j < i; j++) { System.out.pritl(
More informationWRITTEN ASSIGNMENT 1 ANSWER KEY
CISC 65 Itrodutio Desig ad Aalysis of Algorithms WRITTEN ASSIGNMENT ANSWER KEY. Problem -) I geeral, this problem requires f() = some time period be solve for a value. This a be doe for all ase expet lg
More informationLecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem
Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid floorleft right) / 2); MergeSortA, left, mid); MergeSortA,
More informationFIR Filters. Lecture #7 Chapter 5. BME 310 Biomedical Computing - J.Schesser
FIR Filters Lecture #7 Chapter 5 8 What Is this Course All About? To Gai a Appreciatio of the Various Types of Sigals ad Systems To Aalyze The Various Types of Systems To Lear the Skills ad Tools eeded
More informationChapter 6. Advanced Counting Techniques
Chapter 6 Advaced Coutig Techiques 6.: Recurrece Relatios Defiitio: A recurrece relatio for the sequece {a } is a equatio expressig a i terms of oe or more of the previous terms of the sequece: a,a2,a3,,a
More informationAddition: Property Name Property Description Examples. a+b = b+a. a+(b+c) = (a+b)+c
Notes for March 31 Fields: A field is a set of umbers with two (biary) operatios (usually called additio [+] ad multiplicatio [ ]) such that the followig properties hold: Additio: Name Descriptio Commutativity
More informationAn Introduction to Randomized Algorithms
A Itroductio to Radomized Algorithms The focus of this lecture is to study a radomized algorithm for quick sort, aalyze it usig probabilistic recurrece relatios, ad also provide more geeral tools for aalysis
More informationAmortized Analysis - Part 2 - Dynamic Tables. Objective: In this lecture, we shall explore Dynamic tables and its amortized analysis in detail.
Idia Istitute of Iformatio Techology Desig ad Maufacturig, Kacheepuram Cheai 600 17, Idia A Autoomous Istitute uder MHRD, Govt of Idia http://www.iiitdm.ac.i COM 501 Advaced Data Structures ad Algorithms
More informationOPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES
OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES Peter M. Maurer Why Hashig is θ(). As i biary search, hashig assumes that keys are stored i a array which is idexed by a iteger. However, hashig attempts to bypass
More informationMath 155 (Lecture 3)
Math 55 (Lecture 3) September 8, I this lecture, we ll cosider the aswer to oe of the most basic coutig problems i combiatorics Questio How may ways are there to choose a -elemet subset of the set {,,,
More informationAlgebra of Least Squares
October 19, 2018 Algebra of Least Squares Geometry of Least Squares Recall that out data is like a table [Y X] where Y collects observatios o the depedet variable Y ad X collects observatios o the k-dimesioal
More informationYou may work in pairs or purely individually for this assignment.
CS 04 Problem Solvig i Computer Sciece OOC Assigmet 6: Recurreces You may work i pairs or purely idividually for this assigmet. Prepare your aswers to the followig questios i a plai ASCII text file or
More information6.046 Recitation 5: Binary Search Trees Bill Thies, Fall 2004 Outline
6.046 Recitatio 5: Biary Search Trees Bill Thies, Fall 2004 Outlie My cotact iformatio: Bill Thies thies@mit.edu Office hours: Sat 1-3pm, 36-153 Recitatio website: http://cag.lcs.mit.edu/~thies/6.046/
More informationORIE 633 Network Flows September 27, Lecture 8
ORIE 633 Network Flows September 7, 007 Lecturer: David P. Williamso Lecture 8 Scribe: Gema Plaza-Martíez 1 Global mi-cuts i udirected graphs 1.1 Radom cotractio Recall from last time we itroduced the
More informationInverse Matrix. A meaning that matrix B is an inverse of matrix A.
Iverse Matrix Two square matrices A ad B of dimesios are called iverses to oe aother if the followig holds, AB BA I (11) The otio is dual but we ofte write 1 B A meaig that matrix B is a iverse of matrix
More informationCS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016
CS161: Algorithm Desig ad Aalysis Hadout #10 Staford Uiversity Wedesday, 10 February 2016 Lecture #11: Wedesday, 10 February 2016 Topics: Example midterm problems ad solutios from a log time ago Sprig
More informationThe Binomial Theorem
The Biomial Theorem Lecture 47 Sectio 9.7 Robb T. Koether Hampde-Sydey College Thu, Apr 8, 03 Robb T. Koether (Hampde-Sydey College The Biomial Theorem Thu, Apr 8, 03 / 7 Combiatios Pascal s Triagle 3
More informationBalanced Dense Polynomial Multiplication on Multicores
Balanced Dense Polynomial Multiplication on Multicores Yuzhen Xie SuperTech Group, CSAIL MIT joint work with Marc Moreno Maza ORCCA, UWO ACA09, Montreal, June 26, 2009 Introduction Motivation: Multicore-enabling
More information