Algorithms Design & Analysis. Divide & Conquer
|
|
- Juliet Snow
- 5 years ago
- Views:
Transcription
1 Algorithms Desig & Aalysis Divide & Coquer
2 Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2
3 Today s topics The divide-ad-coquer desig paradigm Revised master theorem 3
4 The divide-ad-coquer desig paradigm. Divide the problem (istace) ito subproblems. 2. Coquer the subproblems by solvig them recursively. 3. Combie subproblem solutios. 4
5 Example: merge sort. Divide: Trivial. 2. Coquer: Recursively sort 2 subarrays. 3. Combie: Liear-time merge. T() = 2T(/2) + O() # subproblems subproblem size work dividig ad combiig 5
6 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
7 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
8 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
9 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
10 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
11 Biary search Fid a elemet i a sorted array: Divide: Check middle elemet. Coquer: Recursively search subarray. Combie: Trivial. Example: Fid
12 Master theorem (reprise) T() = at(/b) + f () CASE : f () = O( log b a ε ) T() = O( log b a ). CASE 2: f () = Θ( lg b a lg k ) T() = O( log b a lg k+ ). CASE 3: f () = Ω( log b a + ε ) ad a f (/b) c f () T() = Θ( f ()). Merge sort: a = 2, b = 2 log b a = CASE 2 (k = 0) T() = Θ( lg ). 2
13 Recurrece for biary search T() = T(/2) +Θ() # subproblems subproblem size work dividig ad combiig log a b log 2 0 = = = T() = Θ(lg ) CASE 2 (k = 0) 3
14 Powerig a umber Problem: Compute a, where N. Naive algorithm: Θ(). Divide-ad-coquer algorithm: a a a / 2 a / 2 = ( )/ 2 ( )/ 2 a T() = Θ(lg ) a if is eve; if is odd. 4
15 Polyomial multiplicatio Iput: a(x)=a 0 +a x+ +a x, Output: b(x)=b 0 +b x+ +b x, c(x)= a(x)*b(x)=c 0 +c x+ +c 2 x 2 c i =a 0 b i +a b i- + + a i- b +a i b 0 Example: (a 0 +a x) * (b 0 +b x) = a 0 b 0 + (a 0 b +a b 0 )x + a b x 2 = c 0 + c x + c 2 x 2 5
16 Motivatio Essetially equivalet to multiplyig large itegers: 6046*600 = (6* *0 + 0* *0 3 ) * (* *0 + 0* *0 3 ) = a(0) * b(0) = c(0), where c(x)=a(x)*b(x) c(0) = c c c The coefficiets of c form the digits of the product c(0) 6
17 How to multiply two polyomials From the defiitio: Θ( 2 ) time Faster? Use divide ad coquer Divide a(x) = a 0 +a x+ +a x = (a a /2 x /2 ) + x /2 (a /2 x a x /2 ) = p(x) + x /2 q(x) = p + x /2 q I the same way: b(x) = s+x /2 t 7
18 Coquer Observe that a*b = (p+x /2 q) * (s+x /2 t) = p*s + x /2 (p*t+q*s) + x q*t But p,q,s,t have degree /2 ca compute the products recursively! (ad the perform Θ() additios) 8
19 The great momet T() = 4T(/2) +Θ() # subproblems subproblem size work dividig ad combiig log a b log2 4 2 = = CASE T() = Θ( 2 ) No better tha the ordiary algorithm??? 9
20 Need to be more clever Compute: p*s q*t (p+q) * (s+t) = p*s + (p*t + q*s) + q*t (all polyomials have degree /2 ) Ca extract (p*t + q*s) without ay additioal multiplicatios! 20
21 The truly great momet T() = 3T(/2) +Θ() # subproblems subproblem size work dividig ad combiig log a b log = = Much better tha Θ( 2 )! 2
22 22 Matrix multiplicatio Iput: A = [a ij ], B = [b ij ]. Output: C = [c ij ] = A B. } = 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.,,2,, j i K =
23 Stadard algorithm for i to // the i th row do for j to // the j th colum do c ij 0 // the (i th, j th ) elemet for k to do c ij c ij + a ik b kj Ruig time = Θ( 3 ) 23
24 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 s a b = e f t u c d g h C = A B 8 mults of (/2) (/2) submatrices 4 adds of (/2) (/2) submatrices 24
25 Aalysis of D&C algorithm T() = 8T(/2) +Θ( 2 ) # subproblems subproblem size work dividig ad combiig log a b log2 8 3 = = CASE T() = Θ( 3 ) No better tha the ordiary algorithm. 25
26 Strasse s idea(969) Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) r = P5 + P4 P2 + P6 P 2 = (a + b) h s = P + P2 P 3 = (c + d) e t = P3 + P4 P 4 = d (g e) u = P5 + P P3 P7 P 5 = (a + d) (e + h) P 6 = (b d) (g + h) P 7 = (a c) (e + f ) 7 mults, 8 adds/subs. Note: No reliace o commutativity of mult! 26
27 Strasse s idea Multiply 2 2 matrices with oly 7 recursive mults. P = a ( f h) r = P5 + P4 P2 + P6 P 2 = (a + b) h = (a + d) (e + h) P 3 = (c + d) e + d (g e) (a + b) h P 4 = d (g e) + (b d) (g + h) P 5 = (a + d) (e + h) = ae + ah + de + dh P 6 = (b d) (g + h) + dg de ah bh P 7 = (a c) (e + f ) + bg+ bh dg dh = ae + bg 27
28 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() = 7T(/2) + Θ( 2 ) 28
29 Aalysis of Strasse loga b log T() = 7T(/2) + Θ( 2 ) = CASE T() = Θ( lg7 ) 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 30 or so. Best to date (of theoretical iterest oly): Θ( ). 29
30 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). Ca lead to more efficiet algorithms 30
31 VLSI layout Problem: Embed a complete biary tree with leaves i a grid usig miimal area. 3
32 H-tree embeddig 32
33 Fiboacci umbers Recursive defiitio: F = 0 F if if = = 0; ; F 2 if 2. Naive recursive algorithm: Ω(φ ) (expoetial time), where φ = ( + 5) / 2 is the golde ratio. 33
34 Computig Fiboacci Numbers 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. Bottom-up: Compute F 0, F, F 2,, F i order, formig each umber by summig the two previous. Ruig time: Θ(). 34
35 35 Recursive squarig Theorem: Algorithm: Recursive squarig. Time = Θ (lg ). Proof of theorem. (Iductio o.) Base ( = ): F F F F = = F F F F
36 36 Recursive squarig Iductive step ( 2): = F F F F F F F F = 0 0 = 0
37 Next week Dyamic programmig Chapter 5 37
Introduction 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationProperties and Tests of Zeros of Polynomial Functions
Properties ad Tests of Zeros of Polyomial Fuctios The Remaider ad Factor Theorems: Sythetic divisio ca be used to fid the values of polyomials i a sometimes easier way tha substitutio. This is show by
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 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 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 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 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 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 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 / 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 informationAlgorithms and Data Structures 2014 Exercises and Solutions Week 13
Algorithms ad Data Structures 204 Exercises ad Solutios Week 3 Toom-Cook (cotiued) Durig the last lecture, two polyomials A(x) a 0 + a x ad B(x) b 0 + b x both of degree were multiplied, first by evaluatig
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 information1 Summary: Binary and Logic
1 Summary: Biary ad Logic Biary Usiged Represetatio : each 1-bit is a power of two, the right-most is for 2 0 : 0110101 2 = 2 5 + 2 4 + 2 2 + 2 0 = 32 + 16 + 4 + 1 = 53 10 Usiged Rage o bits is [0...2
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 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 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 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 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 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 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 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 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 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 informationAN ALMOST LINEAR RECURRENCE. Donald E. Knuth Calif. Institute of Technology, Pasadena, Calif.
AN ALMOST LINEAR RECURRENCE Doald E. Kuth Calif. Istitute of Techology, Pasadea, Calif. form A geeral liear recurrece with costat coefficiets has the U 0 = a l* U l = a 2 " ' " U r - l = a r ; u = b, u,
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 informationEnumerative & Asymptotic Combinatorics
C50 Eumerative & Asymptotic Combiatorics Notes 4 Sprig 2003 Much of the eumerative combiatorics of sets ad fuctios ca be geeralised i a maer which, at first sight, seems a bit umotivated I this chapter,
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 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 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 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 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 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 informationBasic Sets. Functions. MTH299 - Examples. Example 1. Let S = {1, {2, 3}, 4}. Indicate whether each statement is true or false. (a) S = 4. (e) 2 S.
Basic Sets Example 1. Let S = {1, {2, 3}, 4}. Idicate whether each statemet is true or false. (a) S = 4 (b) {1} S (c) {2, 3} S (d) {1, 4} S (e) 2 S. (f) S = {1, 4, {2, 3}} (g) S Example 2. Compute the
More informationSolutions to Problem Set 8
8.78 Solutios to Problem Set 8. We ow that ( ) ( + x) x. Now we plug i x, ω, ω ad add the three equatios. If 3 the we ll get a cotributio of + ω + ω + ω + ω 0, whereas if 3 we ll get a cotributio of +
More informationPolynomials with Rational Roots that Differ by a Non-zero Constant. Generalities
Polyomials with Ratioal Roots that Differ by a No-zero Costat Philip Gibbs The problem of fidig two polyomials P(x) ad Q(x) of a give degree i a sigle variable x that have all ratioal roots ad differ by
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 informationFFTs in Graphics and Vision. The Fast Fourier Transform
FFTs i Graphics ad Visio The Fast Fourier Trasform 1 Outlie The FFT Algorithm Applicatios i 1D Multi-Dimesioal FFTs More Applicatios Real FFTs 2 Computatioal Complexity To compute the movig dot-product
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 informationThe Discrete Fourier Transform
The Discrete Fourier Trasform Complex Fourier Series Represetatio Recall that a Fourier series has the form a 0 + a k cos(kt) + k=1 b k si(kt) This represetatio seems a bit awkward, sice it ivolves two
More informationIntroduction To Discrete Mathematics
Itroductio To Discrete Mathematics Review If you put + pigeos i pigeoholes the at least oe hole would have more tha oe pigeo. If (r + objects are put ito boxes, the at least oe of the boxes cotais r or
More informationOrder doesn t matter. There exists a number (zero) whose sum with any number is the number.
P. Real Numbers ad Their Properties Natural Numbers 1,,3. Whole Numbers 0, 1,,... Itegers..., -1, 0, 1,... Real Numbers Ratioal umbers (p/q) Where p & q are itegers, q 0 Irratioal umbers o-termiatig ad
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 informationDefinitions and Theorems. where x are the decision variables. c, b, and a are constant coefficients.
Defiitios ad Theorems Remember the scalar form of the liear programmig problem, Miimize, Subject to, f(x) = c i x i a 1i x i = b 1 a mi x i = b m x i 0 i = 1,2,, where x are the decisio variables. c, b,
More informationPolynomial identity testing and global minimum cut
CHAPTER 6 Polyomial idetity testig ad global miimum cut I this lecture we will cosider two further problems that ca be solved usig probabilistic algorithms. I the first half, we will cosider the problem
More informationMATH 324 Summer 2006 Elementary Number Theory Solutions to Assignment 2 Due: Thursday July 27, 2006
MATH 34 Summer 006 Elemetary Number Theory Solutios to Assigmet Due: Thursday July 7, 006 Departmet of Mathematical ad Statistical Scieces Uiversity of Alberta Questio [p 74 #6] Show that o iteger of the
More informationLESSON 2: SIMPLIFYING RADICALS
High School: Workig with Epressios LESSON : SIMPLIFYING RADICALS N.RN.. C N.RN.. B 5 5 C t t t t t E a b a a b N.RN.. 4 6 N.RN. 4. N.RN. 5. N.RN. 6. 7 8 N.RN. 7. A 7 N.RN. 8. 6 80 448 4 5 6 48 00 6 6 6
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 informationREVISION SHEET FP1 (MEI) ALGEBRA. Identities In mathematics, an identity is a statement which is true for all values of the variables it contains.
The mai ideas are: Idetities REVISION SHEET FP (MEI) ALGEBRA Before the exam you should kow: If a expressio is a idetity the it is true for all values of the variable it cotais The relatioships betwee
More information[ 11 ] z of degree 2 as both degree 2 each. The degree of a polynomial in n variables is the maximum of the degrees of its terms.
[ 11 ] 1 1.1 Polyomial Fuctios 1 Algebra Ay fuctio f ( x) ax a1x... a1x a0 is a polyomial fuctio if ai ( i 0,1,,,..., ) is a costat which belogs to the set of real umbers ad the idices,, 1,...,1 are atural
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 informationNorthwest High School s Algebra 2/Honors Algebra 2 Summer Review Packet
Northwest High School s Algebra /Hoors Algebra Summer Review Packet This packet is optioal! It will NOT be collected for a grade et school year! This packet has bee desiged to help you review various mathematical
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 informationSolutions to Tutorial 3 (Week 4)
The Uiversity of Sydey School of Mathematics ad Statistics Solutios to Tutorial Week 4 MATH2962: Real ad Complex Aalysis Advaced Semester 1, 2017 Web Page: http://www.maths.usyd.edu.au/u/ug/im/math2962/
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 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 information11. Hash Tables. m is not too large. Many applications require a dynamic set that supports only the directory operations INSERT, SEARCH and DELETE.
11. Hash Tables May applicatios require a dyamic set that supports oly the directory operatios INSERT, SEARCH ad DELETE. A hash table is a geeralizatio of the simpler otio of a ordiary array. Directly
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 informationREVISION SHEET FP1 (MEI) ALGEBRA. Identities In mathematics, an identity is a statement which is true for all values of the variables it contains.
the Further Mathematics etwork wwwfmetworkorguk V 07 The mai ideas are: Idetities REVISION SHEET FP (MEI) ALGEBRA Before the exam you should kow: If a expressio is a idetity the it is true for all values
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 informationMath 2784 (or 2794W) University of Connecticut
ORDERS OF GROWTH PAT SMITH Math 2784 (or 2794W) Uiversity of Coecticut Date: Mar. 2, 22. ORDERS OF GROWTH. Itroductio Gaiig a ituitive feel for the relative growth of fuctios is importat if you really
More informationTheorem: Let A n n. In this case that A does reduce to I, we search for A 1 as the solution matrix X to the matrix equation A X = I i.e.
Theorem: Let A be a square matrix The A has a iverse matrix if ad oly if its reduced row echelo form is the idetity I this case the algorithm illustrated o the previous page will always yield the iverse
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 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 informationHomework 9. (n + 1)! = 1 1
. Chapter : Questio 8 If N, the Homewor 9 Proof. We will prove this by usig iductio o. 2! + 2 3! + 3 4! + + +! +!. Base step: Whe the left had side is. Whe the right had side is 2! 2 +! 2 which proves
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 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 informationLECTURE 8: ORTHOGONALITY (CHAPTER 5 IN THE BOOK)
LECTURE 8: ORTHOGONALITY (CHAPTER 5 IN THE BOOK) Everythig marked by is ot required by the course syllabus I this lecture, all vector spaces is over the real umber R. All vectors i R is viewed as a colum
More informationME NUMERICAL METHODS Fall 2007
ME - 310 NUMERICAL METHODS Fall 2007 Group 02 Istructor: Prof. Dr. Eres Söylemez (Rm C205, email:eres@metu.edu.tr ) Class Hours ad Room: Moday 13:40-15:30 Rm: B101 Wedesday 12:40-13:30 Rm: B103 Course
More informationThe Method of Least Squares. To understand least squares fitting of data.
The Method of Least Squares KEY WORDS Curve fittig, least square GOAL To uderstad least squares fittig of data To uderstad the least squares solutio of icosistet systems of liear equatios 1 Motivatio Curve
More information