Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication
|
|
- William Beasley
- 6 years ago
- Views:
Transcription
1 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
2 The divide-ad-coquer desig paradigm. Divide the problem (istace) ito subproblems. 2. Coquer the subproblems by solvig them recursively. 3. Combie subproblem solutios. September 5, 2004 Itroductio to Algorithms L3.2
3 Merge sort. Divide: Trivial. 2. Coquer: Recursively sort 2 subarrays. 3. Combie: Liear-time merge. September 5, 2004 Itroductio to Algorithms L3.3
4 Merge sort. Divide: Trivial. 2. Coquer: Recursively sort 2 subarrays. 3. Combie: Liear-time merge. T() = 2 T(/2) + Θ() # subproblems subproblem size work dividig ad combiig September 5, 2004 Itroductio to Algorithms L3.4
5 Master theorem (reprise) T() = at(/b) + f () CASE : f () = O( log ba ε ), costat ε > 0 T() = Θ( log ba ). CASE 2: f () = Θ( log ba lg k ), costat k 0 T() = Θ( log ba lg k+ ). CASE 3: f () = Ω( log ba + ε ), costat ε > 0, ad regularity coditio T() = Θ( f ()). September 5, 2004 Itroductio to Algorithms L3.5
6 September 5, 2004 Master theorem (reprise) T() = at(/b) + f () CASE : f () = O( log ba ε ), costat ε > 0 T() = Θ( log ba ). CASE 2: f () = Θ( log ba lg k ), costat k 0 T() = Θ( log ba lg k+ ). CASE 3: f () = Ω( log ba + ε ), costat ε > 0, ad regularity coditio T() = Θ( f ()). Merge sort: a = 2, b = 2 log ba = log 22 = CASE 2 (k = 0) T() = Θ( lg ). Itroductio to Algorithms L3.6
7 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. September 5, 2004 Itroductio to Algorithms L3.7
8 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.8
9 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.9
10 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.0
11 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.
12 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.2
13 Biary search Fid a elemet i a sorted array:. Divide: Check middle elemet. 2. Coquer: Recursively search subarray. 3. Combie: Trivial. Example: Fid September 5, 2004 Itroductio to Algorithms L3.3
14 Recurrece for biary search T() = T(/2) + Θ() # subproblems subproblem size work dividig ad combiig September 5, 2004 Itroductio to Algorithms L3.4
15 Recurrece for biary search T() = T(/2) + Θ() # subproblems subproblem size work dividig ad combiig log ba = log 2 = 0 = CASE 2 (k = 0) T() = Θ(lg ). September 5, 2004 Itroductio to Algorithms L3.5
16 Powerig a umber Problem: Compute a, where N. Naive algorithm: Θ(). September 5, 2004 Itroductio to Algorithms L3.6
17 Powerig a umber Problem: Compute a, where N. Naive algorithm: Θ(). Divide-ad-coquer algorithm: a = a /2 a /2 a ( )/2 a ( )/2 a if is eve; if is odd. September 5, 2004 Itroductio to Algorithms L3.7
18 Powerig a umber Problem: Compute a, where N. Naive algorithm: Θ(). Divide-ad-coquer algorithm: a = a /2 a /2 a ( )/2 a ( )/2 a if is eve; if is odd. T() = T(/2) + Θ() T() = Θ(lg ). September 5, 2004 Itroductio to Algorithms L3.8
19 Fiboacci umbers Recursive defiitio: 0 if = 0; F = if = ; F + F 2 if L September 5, 2004 Itroductio to Algorithms L3.9
20 Fiboacci umbers Recursive defiitio: F = 0 if = 0; if = ; F + F 2 if L Naive recursive algorithm: Ω(φ ) (expoetial time), where φ = ( + is the golde ratio. 5)/2 September 5, 2004 Itroductio to Algorithms L3.20
21 Computig Fiboacci umbers Bottom-up: Compute F 0, F, F 2,, F i order, formig each umber by summig the two previous. Ruig time: Θ(). September 5, 2004 Itroductio to Algorithms L3.2
22 Computig Fiboacci umbers Bottom-up: Compute F 0, F, F 2,, F i order, formig each umber by summig the two previous. Ruig time: Θ(). Naive recursive squarig: F = φ / 5 rouded to the earest iteger. Recursive squarig: Θ(lg ) time. This method is ureliable, sice floatig-poit arithmetic is proe to roud-off errors. September 5, 2004 Itroductio to Algorithms L3.22
23 Recursive squarig F + F Theorem: = F F. 0 September 5, 2004 Itroductio to Algorithms L3.23
24 Recursive squarig F + F Theorem: = F F. 0 Algorithm: Recursive squarig. Time = Θ(lg ). September 5, 2004 Itroductio to Algorithms L3.24
25 September 5, 2004 Itroductio to Algorithms L3.25 Recursive squarig F F F F = + 0 Theorem:. Proof of theorem. (Iductio o.) Base ( = ): = F F F F Algorithm: Recursive squarig. Time = Θ(lg ).
26 September 5, 2004 Itroductio to Algorithms L3.26 Recursive squarig.. Iductive step ( 2): F F F F F F F F = = =
27 September 5, 2004 Itroductio to Algorithms L3.27 Matrix multiplicatio = b b b b b b b b b a a a a a a a a a c c c c c c c c c L M O M M L L L M O M M L L L M O M M L L = = k kj ik ij b a c Iput: A = [a ij ], B = [b ij ]. Output: C = [c ij ] = A B. i, j =, 2,,.
28 Stadard algorithm for i to do for j to do c ij 0 for k to do c ij c ij + a ik b kj September 5, 2004 Itroductio to Algorithms L3.28
29 Stadard algorithm for i to do for j to do c ij 0 for k to do c ij c ij + a ik b kj Ruig time = Θ( 3 ) September 5, 2004 Itroductio to Algorithms L3.29
30 Divide-ad-coquer algorithm IDEA: matrix = 2 2 matrix of (/2) (/2) submatrices: r=ae+bg s=af+bh t =ce+dg u=cf+dh r t s u = a c e g September 5, 2004 Itroductio to Algorithms L3.30 b d C = A B 8 mults of (/2) (/2) submatrices 4 adds of (/2) (/2) submatrices f h
31 Divide-ad-coquer algorithm IDEA: matrix = 2 2 matrix of (/2) (/2) submatrices: r=ae+bg s=af+bh t =ce+dh u=cf+dg r t s u = a c e g September 5, 2004 Itroductio to Algorithms L3.3 b d C = A B recursive 8 mults of (/2) (/2) submatrices ^ 4 adds of (/2) (/2) submatrices f h
32 Aalysis of D&C algorithm T() = 8 T(/2) + Θ( 2 ) # submatrices submatrix size work addig submatrices September 5, 2004 Itroductio to Algorithms L3.32
33 Aalysis of D&C algorithm T() = 8 T(/2) + Θ( 2 ) # submatrices submatrix size work addig submatrices log ba = log 2 8 = 3 CASE T() = Θ( 3 ). September 5, 2004 Itroductio to Algorithms L3.33
34 Aalysis of D&C algorithm T() = 8 T(/2) + Θ( 2 ) # submatrices submatrix size work addig submatrices log ba = log 2 8 = 3 CASE T() = Θ( 3 ). No better tha the ordiary algorithm. September 5, 2004 Itroductio to Algorithms L3.34
35 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. September 5, 2004 Itroductio to Algorithms L3.35
36 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) P 2 = (a + b) h P 3 = (c + d) e P 4 = d (g e) P 5 = (a + d) (e + h) P 6 = (b d) (g + h) P 7 = (a c) (e + f ) September 5, 2004 Itroductio to Algorithms L3.36
37 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) P 2 = (a + b) h P 3 = (c + d) e P 4 = d (g e) P 5 = (a + d) (e + h) P 6 = (b d) (g + h) P 7 = (a c) (e + f ) r = P 5 + P 4 P 2 + P 6 s = P + P 2 t = P 3 + P 4 u = P 5 + P P 3 P 7 September 5, 2004 Itroductio to Algorithms L3.37
38 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) P 2 = (a + b) h P 3 = (c + d) e P 4 = d (g e) P 5 = (a + d) (e + h) P 6 = (b d) (g + h) P 7 = (a c) (e + f ) r = P 5 + P 4 P 2 + P 6 s = P + P 2 t = P 3 + P 4 u = P 5 + P P 3 P 7 7 mults, 8 adds/subs. Note: No reliace o commutativity of mult! September 5, 2004 Itroductio to Algorithms L3.38
39 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) P 2 = (a + b) h P 3 = (c + d) e P 4 = d (g e) P 5 = (a + d) (e + h) P 6 = (b d) (g + h) P 7 = (a c) (e + f ) r = P 5 + P 4 P 2 + P 6 =(a + d)(e + h) + d (g e) (a + b) h + (b d)(g + h) = ae + ah + de + dh + dg de ah bh + bg + bh dg dh = ae + bg September 5, 2004 Itroductio to Algorithms L3.39
40 Strasse s algorithm. Divide: Partitio A ad B ito (/2) (/2) submatrices. Form terms to be multiplied usig + ad. 2. Coquer: Perform 7 multiplicatios of (/2) (/2) submatrices recursively. 3. Combie: Form C usig + ad o (/2) (/2) submatrices. September 5, 2004 Itroductio to Algorithms L3.40
41 Strasse s algorithm. Divide: Partitio A ad B ito (/2) (/2) submatrices. Form terms to be multiplied usig + ad. 2. Coquer: Perform 7 multiplicatios of (/2) (/2) submatrices recursively. 3. Combie: Form C usig + ad o (/2) (/2) submatrices. T() = 7 T(/2) + Θ( 2 ) September 5, 2004 Itroductio to Algorithms L3.4
42 Aalysis of Strasse T() = 7 T(/2) + Θ( 2 ) September 5, 2004 Itroductio to Algorithms L3.42
43 Aalysis of Strasse T() = 7 T(/2) + Θ( 2 ) log ba = log CASE T() = Θ( lg 7 ). September 5, 2004 Itroductio to Algorithms L3.43
44 Aalysis of Strasse T() = 7 T(/2) + Θ( 2 ) log ba = log CASE T() = Θ( lg 7 ). The umber 2.8 may ot seem much smaller tha 3, but because the differece is i the expoet, the impact o ruig time is sigificat. I fact, Strasse s algorithm beats the ordiary algorithm o today s machies for 32 or so. September 5, 2004 Itroductio to Algorithms L3.44
45 Aalysis of Strasse T() = 7 T(/2) + Θ( 2 ) log ba = log CASE T() = Θ( lg 7 ). The umber 2.8 may ot seem much smaller tha 3, but because the differece is i the expoet, the impact o ruig time is sigificat. I fact, Strasse s algorithm beats the ordiary algorithm o today s machies for 32 or so. Best to date (of theoretical iterest oly): Θ( 2.376L ). September 5, 2004 Itroductio to Algorithms L3.45
46 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. September 5, 2004 Itroductio to Algorithms L3.46
47 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. W() H() September 5, 2004 Itroductio to Algorithms L3.47
48 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. W() H() H() = H(/2) + Θ() = Θ(lg ) September 5, 2004 Itroductio to Algorithms L3.48
49 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. W() H() H() = H(/2) + Θ() = Θ(lg ) W() = 2W(/2) + Θ() = Θ() September 5, 2004 Itroductio to Algorithms L3.49
50 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. W() H() H() = H(/2) + Θ() W() = 2W(/2) + Θ() = Θ(lg ) = Θ() Area = Θ( lg ) September 5, 2004 Itroductio to Algorithms L3.50
51 H-tree embeddig L() L() September 5, 2004 Itroductio to Algorithms L3.5
52 H-tree embeddig L() L() L(/4) Θ() L(/4) September 5, 2004 Itroductio to Algorithms L3.52
53 H-tree embeddig L() L() L() = 2L(/4) + Θ() = Θ( ) Area = Θ() L(/4) Θ() L(/4) September 5, 2004 Itroductio to Algorithms L3.53
54 Coclusio Divide ad coquer is just oe of several powerful techiques for algorithm desig. Divide-ad-coquer algorithms ca be aalyzed usig recurreces ad the master method (so practice this math). The divide-ad-coquer strategy ofte leads to efficiet algorithms. September 5, 2004 Itroductio to Algorithms L3.54
Algorithms 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 informationDivide-and-conquer algorithm
Divide-and-conquer algorithm IDEA: n n matrix = 2 2 matrix of (n/2) (n/2) submatrices: r=ae+bg s=af+bh t =ce+dh u=cf+dg r t s u = a c e g September 15, 2004 Introduction to Algorithms L3.31 b d C = A B
More informationIntroduction to Algorithms 6.046J/18.401J/SMA5503
Introduction to Algorithms 6.046J/8.40J/SMA5503 Lecture 3 Prof. Piotr Indyk The divide-and-conquer design paradigm. Divide the problem (instance) into subproblems. 2. Conquer the subproblems by solving
More informationThe Divide-and-Conquer Design Paradigm
CS473- Algorithms I Lecture 4 The Divide-and-Conquer Design Paradigm CS473 Lecture 4 1 The Divide-and-Conquer Design Paradigm 1. Divide the problem (instance) into subproblems. 2. Conquer the subproblems
More informationIntroduction to Algorithms 6.046J/18.401J
Itrodutio to Algorithms.04J/8.40J The divide-d-oquer desig prdigm. Divide the problem (iste) ito subproblems.. Coquer the subproblems by solvig them reursively. 3. Combie subproblem solutios. Leture 3
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 informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS60020: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Matrix multiplication September 14, 2005 L2.27 Standard algorithm for i 1 to n do for j 1 ton do c ij 0 for k 1 to
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationPlan. Analysis of Multithreaded Algorithms. Plan. Matrix multiplication. University of Western Ontario, London, Ontario (Canada) Marc Moreno Maza
Pla Aalysis of Multithreaded Algorithms Marc Moreo Maza Uiversity of Wester Otario, Lodo, Otario (Caada) CS4402-9535 1 2 3 Pla (Moreo Maza) Aalysis of Multithreaded Algorithms CS4402-9535 1 / 27 (Moreo
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 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 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 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 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 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 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 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 informationLecture 3: Divide and Conquer: Fast Fourier Transform
Lecture 3: Divide ad Coquer: Fast Fourier Trasform Polyomial Operatios vs. Represetatios Divide ad Coquer Algorithm Collapsig Samples / Roots of Uity FFT, IFFT, ad Polyomial Multiplicatio Polyomial operatios
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 informationMatrix Multiplication. Data Structures and Algorithms Andrei Bulatov
Matrix Multiplicatio Data Structures ad Algorithms Adrei Bulatov Algorithms Matrix Multiplicatio 7- Matrix Multiplicatio Matrix multiplicatio. Give two -by- matrices A ad B, compute A B. k kj ik ij b a
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 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 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 informationCSE 1400 Applied Discrete Mathematics Number Theory and Proofs
CSE 1400 Applied Discrete Mathematics Number Theory ad Proofs Departmet of Computer Scieces College of Egieerig Florida Tech Sprig 01 Problems for Number Theory Backgroud Number theory is the brach of
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 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 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 information1. By using truth tables prove that, for all statements P and Q, the statement
Author: Satiago Salazar Problems I: Mathematical Statemets ad Proofs. By usig truth tables prove that, for all statemets P ad Q, the statemet P Q ad its cotrapositive ot Q (ot P) are equivalet. I example.2.3
More informationHand Out: Analysis of Algorithms. September 8, Bud Mishra. In general, there can be several algorithms to solve a problem; and one is faced
Had Out Aalysis of Algorithms September 8, 998 Bud Mishra c Mishra, February 9, 986 Itroductio I geeral, there ca be several algorithms to solve a problem; ad oe is faced with the problem of choosig a
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 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 informationMathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis
Mathematics review for CSCI 303 Sprig 019 Departmet of Computer Sciece College of William & Mary Robert Michael Lewis Copyright 018 019 Robert Michael Lewis Versio geerated: 13 : 00 Jauary 17, 019 Cotets
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 informationCHAPTER I: Vector Spaces
CHAPTER I: Vector Spaces Sectio 1: Itroductio ad Examples This first chapter is largely a review of topics you probably saw i your liear algebra course. So why cover it? (1) Not everyoe remembers everythig
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 informationAlgorithm Analysis. Chapter 3
Data Structures Dr Ahmed Rafat Abas Computer Sciece Dept, Faculty of Computer ad Iformatio, Zagazig Uiversity arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Algorithm Aalysis Chapter 3 3. Itroductio
More informationExam 2 CMSC 203 Fall 2009 Name SOLUTION KEY Show All Work! 1. (16 points) Circle T if the corresponding statement is True or F if it is False.
1 (1 poits) Circle T if the correspodig statemet is True or F if it is False T F For ay positive iteger,, GCD(, 1) = 1 T F Every positive iteger is either prime or composite T F If a b mod p, the (a/p)
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 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 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 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 informationHomework 3. = k 1. Let S be a set of n elements, and let a, b, c be distinct elements of S. The number of k-subsets of S is
Homewor 3 Chapter 5 pp53: 3 40 45 Chapter 6 p85: 4 6 4 30 Use combiatorial reasoig to prove the idetity 3 3 Proof Let S be a set of elemets ad let a b c be distict elemets of S The umber of -subsets of
More informationQuantum Computing Lecture 7. Quantum Factoring
Quatum Computig Lecture 7 Quatum Factorig Maris Ozols Quatum factorig A polyomial time quatum algorithm for factorig umbers was published by Peter Shor i 1994. Polyomial time meas that the umber of gates
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 informationTrial division, Pollard s p 1, Pollard s ρ, and Fermat s method. Christopher Koch 1. April 8, 2014
Iteger Divisio Algorithm ad Cogruece Iteger Trial divisio,,, ad with itegers mod Iverses mod Multiplicatio ad GCD Iteger Christopher Koch 1 1 Departmet of Computer Sciece ad Egieerig CSE489/589 Algorithms
More information1 Generating functions for balls in boxes
Math 566 Fall 05 Some otes o geeratig fuctios Give a sequece a 0, a, a,..., a,..., a geeratig fuctio some way of represetig the sequece as a fuctio. There are may ways to do this, with the most commo ways
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 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 informationSignals & Systems Chapter3
Sigals & Systems Chapter3 1.2 Discrete-Time (D-T) Sigals Electroic systems do most of the processig of a sigal usig a computer. A computer ca t directly process a C-T sigal but istead eeds a stream of
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 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 informationGenerating Functions II
Geeratig Fuctios II Misha Lavrov ARML Practice 5/4/2014 Warm-up problems 1. Solve the recursio a +1 = 2a, a 0 = 1 by usig commo sese. 2. Solve the recursio b +1 = 2b + 1, b 0 = 1 by usig commo sese ad
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 informationSequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence
Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece 1, 1, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet
More informationIn number theory we will generally be working with integers, though occasionally fractions and irrationals will come into play.
Number Theory Math 5840 otes. Sectio 1: Axioms. I umber theory we will geerally be workig with itegers, though occasioally fractios ad irratioals will come ito play. Notatio: Z deotes the set of all itegers
More informationAPPENDIX F Complex Numbers
APPENDIX F Complex Numbers Operatios with Complex Numbers Complex Solutios of Quadratic Equatios Polar Form of a Complex Number Powers ad Roots of Complex Numbers Operatios with Complex Numbers Some equatios
More informationWe are mainly going to be concerned with power series in x, such as. (x)} converges - that is, lims N n
Review of Power Series, Power Series Solutios A power series i x - a is a ifiite series of the form c (x a) =c +c (x a)+(x a) +... We also call this a power series cetered at a. Ex. (x+) is cetered at
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 informationAssignment 5: Solutions
McGill Uiversity Departmet of Mathematics ad Statistics MATH 54 Aalysis, Fall 05 Assigmet 5: Solutios. Let y be a ubouded sequece of positive umbers satisfyig y + > y for all N. Let x be aother sequece
More informationA sequence of numbers is a function whose domain is the positive integers. We can see that the sequence
Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece,, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet as
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 informationIntensive Algorithms Lecture 11. DFT and DP. Lecturer: Daniel A. Spielman February 20, f(n) O(g(n) log c g(n)).
Itesive Algorithms Lecture 11 DFT ad DP Lecturer: Daiel A. Spielma February 20, 2018 11.1 Itroductio The purpose of this lecture is to lear how use the Discrete Fourier Trasform to save space i Dyamic
More information2.4 - Sequences and Series
2.4 - Sequeces ad Series Sequeces A sequece is a ordered list of elemets. Defiitio 1 A sequece is a fuctio from a subset of the set of itegers (usually either the set 80, 1, 2, 3,... < or the set 81, 2,
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 informationA Probabilistic Analysis of Quicksort
A Probabilistic Aalysis of Quicsort You are assumed to be familiar with Quicsort. I each iteratio this sortig algorithm chooses a pivot ad the, by performig comparisios with the pivot, splits the remaider
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 informationSECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES
SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES Read Sectio 1.5 (pages 5 9) Overview I Sectio 1.5 we lear to work with summatio otatio ad formulas. We will also itroduce a brief overview of sequeces,
More informationLecture 2 Clustering Part II
COMS 4995: Usupervised Learig (Summer 8) May 24, 208 Lecture 2 Clusterig Part II Istructor: Nakul Verma Scribes: Jie Li, Yadi Rozov Today, we will be talkig about the hardess results for k-meas. More specifically,
More informationTEACHER CERTIFICATION STUDY GUIDE
COMPETENCY 1. ALGEBRA SKILL 1.1 1.1a. ALGEBRAIC STRUCTURES Kow why the real ad complex umbers are each a field, ad that particular rigs are ot fields (e.g., itegers, polyomial rigs, matrix rigs) Algebra
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 2112 Solutions Assignment 5
Math 2112 Solutios Assigmet 5 5.1.1 Idicate which of the followig relatioships are true ad which are false: a. Z Q b. R Q c. Q Z d. Z Z Z e. Q R Q f. Q Z Q g. Z R Z h. Z Q Z a. True. Every positive iteger
More informationCHAPTER 1 SEQUENCES AND INFINITE SERIES
CHAPTER SEQUENCES AND INFINITE SERIES SEQUENCES AND INFINITE SERIES (0 meetigs) Sequeces ad limit of a sequece Mootoic ad bouded sequece Ifiite series of costat terms Ifiite series of positive terms Alteratig
More informationLecture 20. Brief Review of Gram-Schmidt and Gauss s Algorithm
8.409 A Algorithmist s Toolkit Nov. 9, 2009 Lecturer: Joatha Keler Lecture 20 Brief Review of Gram-Schmidt ad Gauss s Algorithm Our mai task of this lecture is to show a polyomial time algorithm which
More informationCHAPTER 5. Theory and Solution Using Matrix Techniques
A SERIES OF CLASS NOTES FOR 2005-2006 TO INTRODUCE LINEAR AND NONLINEAR PROBLEMS TO ENGINEERS, SCIENTISTS, AND APPLIED MATHEMATICIANS DE CLASS NOTES 3 A COLLECTION OF HANDOUTS ON SYSTEMS OF ORDINARY DIFFERENTIAL
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 informationSect 5.3 Proportions
Sect 5. Proportios Objective a: Defiitio of a Proportio. A proportio is a statemet that two ratios or two rates are equal. A proportio takes a form that is similar to a aalogy i Eglish class. For example,
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 informationHomework 1 Solutions. The exercises are from Foundations of Mathematical Analysis by Richard Johnsonbaugh and W.E. Pfaffenberger.
Homewor 1 Solutios Math 171, Sprig 2010 Hery Adams The exercises are from Foudatios of Mathematical Aalysis by Richard Johsobaugh ad W.E. Pfaffeberger. 2.2. Let h : X Y, g : Y Z, ad f : Z W. Prove that
More information