Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Similar documents
Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1)

5. Solving recurrences

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Section IV.6: The Master Method and Applications

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer


1.3 Continuous Functions and Riemann Sums

Fast Fourier Transform 1) Legendre s Interpolation 2) Vandermonde Matrix 3) Roots of Unity 4) Polynomial Evaluation

Discrete Mathematics I Tutorial 12

Taylor Polynomials. The Tangent Line. (a, f (a)) and has the same slope as the curve y = f (x) at that point. It is the best

( a n ) converges or diverges.

A GENERAL METHOD FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS: THE FROBENIUS (OR SERIES) METHOD

Week 13 Notes: 1) Riemann Sum. Aim: Compute Area Under a Graph. Suppose we want to find out the area of a graph, like the one on the right:

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

Algorithms and Data Structures Lecture IV

Divide-and-Conquer. Divide-and-Conquer 1

Chapter 7 Infinite Series

8.3 Sequences & Series: Convergence & Divergence

10. 3 The Integral and Comparison Test, Estimating Sums

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

Unit 1 Chapter-3 Partial Fractions, Algebraic Relationships, Surds, Indices, Logarithms

10.5 Power Series. In this section, we are going to start talking about power series. A power series is a series of the form

Numbers (Part I) -- Solutions

Surds, Indices, and Logarithms Radical

0 otherwise. sin( nx)sin( kx) 0 otherwise. cos( nx) sin( kx) dx 0 for all integers n, k.

Relation of BSTs to Quicksort, Analysis of Random BST. Lecture 9

The Basic Properties of the Integral

) 2 2(2. Assume that

MAS221 Analysis, Semester 2 Exercises

SOLUTION OF SYSTEM OF LINEAR EQUATIONS. Lecture 4: (a) Jacobi's method. method (general). (b) Gauss Seidel method.

MTH 146 Class 16 Notes

General properties of definite integrals

Advanced Algorithmic Problem Solving Le 6 Math and Search

Fig. 1. I a. V ag I c. I n. V cg. Z n Z Y. I b. V bg

f ( x) ( ) dx =

Handout #2. Introduction to Matrix: Matrix operations & Geometric meaning

Crushed Notes on MATH132: Calculus

UNIVERSITY OF BRISTOL. Examination for the Degrees of B.Sc. and M.Sci. (Level C/4) ANALYSIS 1B, SOLUTIONS MATH (Paper Code MATH-10006)

Test Info. Test may change slightly.

M3P14 EXAMPLE SHEET 1 SOLUTIONS

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

Linford 1. Kyle Linford. Math 211. Honors Project. Theorems to Analyze: Theorem 2.4 The Limit of a Function Involving a Radical (A4)

CS 331 Design and Analysis of Algorithms. -- Divide and Conquer. Dr. Daisy Tang

Lecture 38 (Trapped Particles) Physics Spring 2018 Douglas Fields

Section 11.5 Notes Page Partial Fraction Decomposition. . You will get: +. Therefore we come to the following: x x

THE NATIONAL UNIVERSITY OF IRELAND, CORK COLÁISTE NA hollscoile, CORCAIGH UNIVERSITY COLLEGE, CORK SUMMER EXAMINATION 2005 FIRST ENGINEERING

Important Facts You Need To Know/Review:

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5

Pre-Calculus - Chapter 3 Sections Notes

Approximate Integration

Mathacle. PSet Stats, Concepts In Statistics Level Number Name: Date:

Section 6.3: Geometric Sequences

Review of Sections

For students entering Honors Precalculus Summer Packet

1. (25 points) Use the limit definition of the definite integral and the sum formulas to compute. [1 x + x2

f(t)dt 2δ f(x) f(t)dt 0 and b f(t)dt = 0 gives F (b) = 0. Since F is increasing, this means that

Limit of a function:

4.3 Growth Rates of Solutions to Recurrences

In an algebraic expression of the form (1), like terms are terms with the same power of the variables (in this case

PROGRESSIONS AND SERIES

Simpson s 1/3 rd Rule of Integration

GRAPHING LINEAR EQUATIONS. Linear Equations. x l ( 3,1 ) _x-axis. Origin ( 0, 0 ) Slope = change in y change in x. Equation for l 1.

lecture 16: Introduction to Least Squares Approximation

SM2H. Unit 2 Polynomials, Exponents, Radicals & Complex Numbers Notes. 3.1 Number Theory

Review of the Riemann Integral

 n. A Very Interesting Example + + = d. + x3. + 5x4. math 131 power series, part ii 7. One of the first power series we examined was. 2!

z line a) Draw the single phase equivalent circuit. b) Calculate I BC.

Convergence rates of approximate sums of Riemann integrals

Data Structures and Algorithms

Math 2414 Activity 17 (Due with Final Exam) Determine convergence or divergence of the following alternating series: a 3 5 2n 1 2n 1

Graphing Review Part 3: Polynomials

Numerical Solutions of Fredholm Integral Equations Using Bernstein Polynomials

Second Mean Value Theorem for Integrals By Ng Tze Beng. The Second Mean Value Theorem for Integrals (SMVT) Statement of the Theorem

8.1 Arc Length. What is the length of a curve? How can we approximate it? We could do it following the pattern we ve used before

Data Structures Lecture 9

MA123, Chapter 9: Computing some integrals (pp )

4. When is the particle speeding up? Why? 5. When is the particle slowing down? Why?

Sect Simplifying Radical Expressions. We can use our properties of exponents to establish two properties of radicals: and

n 2 + 3n + 1 4n = n2 + 3n + 1 n n 2 = n + 1

=> PARALLEL INTERCONNECTION. Basic Properties LTI Systems. The Commutative Property. Convolution. The Commutative Property. The Distributive Property

INFINITE SERIES. ,... having infinite number of terms is called infinite sequence and its indicated sum, i.e., a 1

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

We will begin by supplying the proof to (a).

10.5 Test Info. Test may change slightly.

Fundamental Algorithms

Laws of Integral Indices

Calculus II Homework: The Integral Test and Estimation of Sums Page 1

is an ordered list of numbers. Each number in a sequence is a term of a sequence. n-1 term

9.1 Sequences & Series: Convergence & Divergence

Project 3: Using Identities to Rewrite Expressions

Remarks: (a) The Dirac delta is the function zero on the domain R {0}.

CS 332: Algorithms. Quicksort

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

Recurrence Relations

Numerical Methods (CENG 2002) CHAPTER -III LINEAR ALGEBRAIC EQUATIONS. In this chapter, we will deal with the case of determining the values of x 1

ICS141: Discrete Mathematics for Computer Science I

Fundamentals of Mathematics. Pascal s Triangle An Investigation March 20, 2008 Mario Soster

INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

CH 39 USING THE GCF TO REDUCE FRACTIONS

Transcription:

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, mid+, right); MergeA, left, mid, right); } } // Merge) tes two sorted surrys of A d // merges them ito sigle sorted surry of A // how log should this te?) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Alysis of Merge Sort Sttemet MergeSortA, left, right) { if left < right) { mid = floorleft + right) / 2); MergeSortA, left, mid); MergeSortA, mid+, right); MergeA, left, mid, right); } } So T) = ) whe =, d 2T/2) + ) whe > So wht more succictly) is T)? Effort T) ) ) T/2) T/2) ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Recurreces The expressio: T ) 2T c 2 c is recurrece. Recurrece: equtio tht descries fuctio i terms of its vlue o smller fuctios CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov Recurrece Exmples ) ) s c s ) ) s s 2 2 ) c T c T ) c T c T

Solvig Recurreces Itertio method Mster method Sustitutio method CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces itertio method Expd the recurrece Wor some lger to express s summtio Evlute the summtio We will show severl exmples CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Eg. - Lier Serch Recursively Loo t elemet costt wor, c), the serch the remiig elemets T) = T - ) + c The cost of serchig elemets is the cost of looig t elemet, plus the cost of serchig - elemets CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Lier Serch cot.) We ll uwid few of these T) = T-) + c ) But, T-) = T-2) + c, from ove Sustitutig c i: T) = T-2) + c + c Gtherig lie terms T) = T-2) + 2c 2) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Lier Serch cot.) Keep goig: T) = T-2) + 2c T-2) = T-3) + c T) = T-3) + c + 2c T) = T-3) + 3c 3) Oe more: T) = T-4) + 4c 4) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Looig for Ptters Note, the itermedite results re eumerted We eed to pull out ptters, to write geerl expressio for the th uwidig This requires prctise Be creful while simplifyig fter sustitutio CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Eg. list of itermedites Result t i th uwidig i T) = T-) + c T) = T-2) + 2c 2 T) = T-3) + 3c 3 T) = T-4) + 4c 4 CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Lier Serch cot.) A expressio for the th uwidig: T) = T-) + c We hve 2 vriles, d, ut we hve reltio Td) is costt c e determied) for some costt d we ow the lgorithm) Choose y coveiet # to stop. CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Lier Serch cot.) Let s decide to stop t T). Whe the list to serch is empty, you re doe is coveiet, i this exmple Let - = => = Now, sustitute i everywhere for : T) = T-) + c T) = T) + c = c + c = O) T) is some costt, c ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch T) T/2) T/4) T/8) Algorithm split rry, the serch lower ½ or upper ½ T) = T/2) + c where c is some costt, the cost of fidig the middle for the split CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot) Let s do some quic sustitutios: T) = T/2) + c ) ut T/2) = T/4) + c, so T) = T/4) + c + c T) = T/4) + 2c 2) T/4) = T/8) + c T) = T/8) + c + 2c T) = T/8) + 3c 3) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot.) Result t i th uwidig i T) = T/2) + c T) = T/4) + 2c 2 T) = T/8) + 3c 3 T) = T/6) + 4c 4 CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot) We eed to write expressio for the th uwidig i & ) Must fid ptters, chges, s i=, 2,, This c e the hrd prt Do ot get discourged! Try somethig else We ll re-write those equtios We will the eed to relte d CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot) Result t i th uwidig i T) = T/2) + c =T/2 ) + c T) = T/4) + 2c =T/2 2 ) + 2c 2 T) = T/8) + 3c =T/2 3 ) + 3c 3 T) = T/6) + 4c =T/2 4 ) + 4c 4 CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot) After uwidigs: T) = T/2 ) + c Need coveiet plce to stop uwidig eed to relte & Let s pic T) = c So, /2 = => = Hmm. Esy, ut ot useful CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot) Oy, let s cosider T) = c So, let: /2 = => = 2 => = log 2 = lg CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Biry Serch cot.) Sustitutig c i gettig rid of ): T) = T) + c lg) = c lg) + c = O lg) ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

T ) Itertio Method T ) f ) for for The itertio method or uwidig the recurrece): T) = f) + T ) = f) + f-) + T 2) = f) + f-) + f-2) + T 3) = = f) + f-) + f-2) + + f3) + f2) + T) = f) + f-) + f-2) + + f3) + f2) + f) + T) = f) + f-) + f-2) + + f3) + f2) + f). f) is the drivig fuctio of the recurrece Exmple: f) = ) T) = 2 ). f) = 2 ) T) = 2 ). CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Itertio Method T ) 2T for for 2 T) = + 2T/2) = + 2 [/2 + 2T/2 2 )] = 2 + 2 2 T/2 2 ) = 2 + 2 2 [/2 2 + 2 T/2 3 )] = 3 + 2 3 T/2 3 ) = 3 + 2 3 [/2 3 + 2T/2 4 )] = 4 + 2 4 T/2 4 ) = = + 2 T/2 ) te = + log, T/2 ) = = + log ) = log ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Itertio Method cotiued) for T ) 2 2T for T) = 2 + 2T/2) = 2 + 2 [/2) 2 + 2T/2 2 )] = 2 + ½) + 2 2 T/2 2 ) = 2 + ½) + 2 2 [/2 2 ) 2 + 2 T/2 3 )] = 2 + ½ + ½ 2 ) + 2 3 T/2 3 ) = 2 + ½ + ½ 2 ) + 2 3 [/2 3 ) 2 + 2T/2 3 )] = 2 + ½ + ½ 2 + ½ 3 ) + 2 4 T/2 4 ) = 2 = 2 + ½ + ½ 2 + ½ 3 + + ½ ) + 2 + T/2 + ) = 2 + ½ + ½ 3 + ½ 5 + + ½ ) te = log, T/2 + ) = = 2 ) geometric decresig = 2 ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Recursio Tree Method T ) 2T for f ) for 2 T) f) f) T/2) f/2) T/2) f/2) 2f/2) T/4) T/4) T/4) T/4) f/4) f/4) f/4) f/4) T/8) T/8) T/8) T/8) T/8) T/8) T/8) T/8) f/8) f/8) f/8) f/8) f/8) f/8) f/8) f/8) 4f/4) 8f/8) T/6) T ) f ) 2 f log 2 i f 2i 2 ) 4 f 4 ) 8 f ) i CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov 8 T/6)

log 4 log 2 Recursio Tree Method T ) T for T for 4 2 4 4 CLAIM: T) = ). Lower oud: T) W) ovious T) T/4) /4 T/2) /2 3/4 T/6) T/8) T/8) T/4) /6 /8 /8 /4 T/64) T/32) T/32) T/6) T/32) T/6) T/6) T/8) /64 /32 /32 /6 /32 /6 /6 /8 3/4) 2 3/4) 3 T/256) T/6) T ) 3 3 2 3 4 4 4 2 3 3 3 3 4 O ). 4 4 4 3 Upper oud CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

FACT: Recursio Tree Method T ) T for T for 4 2 This is specil cse of the followig recurrece: T) = T) + T) + ) where < d < re rel costt prmeters. ) T) = ) [lier] 2) T) = log ) 3) T) = d ) [super-lier poly] where d > is the uique costt tht stisfies the equtio d + d =. 4 4 CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) s ) s) = c s ) c + s-) c + c + s-2) 2c + s-2) 2c + c + s-3) 3c + s-3) c + s-) = c + s-) T ) T c c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) s ) c s ) So fr for >= we hve s) = c + s-) Wht if =? s) = c + s) = c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) s ) c s ) So fr for >= we hve s) = c + s-) Wht if =? s) = c + s) = c So s ) c s ) Thus i geerl s) = c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) s) s ) = + s-) = + - + s-2) s ) = + - + -2 + s-3) = + - + -2 + -3 + s-4) = = + - + -2 + -3 + + --) + s-) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) s ) s ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov s) = + s-) = + - + s-2) = + - + -2 + s-3) = + - + -2 + -3 + s-4) = = + - + -2 + -3 + + --) + s-) = i s ) i

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov ) ) s s So fr for >= we hve ) s i i Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov ) ) s s So fr for >= we hve Wht if =? ) s i i Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov ) ) s s So fr for >= we hve Wht if =? ) s i i 2 ) i s i i i Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov ) ) s s So fr for >= we hve Wht if =? Thus i geerl ) s i i 2 ) i s i i i 2 ) s Solvig Recurreces exmple)

Solvig Recurreces exmple) T) = T ) 2T c 2 c 2T/2) + c 22T/2/2) + c) + c 2 2 T/2 2 ) + 2c + c 2 2 2T/2 2 /2) + c) + 3c 2 3 T/2 3 ) + 4c + 3c 2 3 T/2 3 ) + 7c 2 3 2T/2 3 /2) + c) + 7c 2 4 T/2 4 ) + 5c 2 T/2 ) + 2 - )c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) T ) 2T So fr for > 2 we hve T) = 2 T/2 ) + 2 - )c Wht if = lg? c 2 c T) = 2 lg T/2 lg ) + 2 lg - )c = T/) + - )c = T) + -)c = c + -)c = 2 - )c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) T) = T/) + c T//) + c/) + c 2 T/ 2 ) + c/ + c 2 T/ 2 ) + c/ + ) 2 T/ 2 /) + c/ 2 ) + c/ + ) 3 T/ 3 ) + c 2 / 2 ) + c/ + ) 3 T/ 3 ) + c 2 / 2 + / + ) T ) T c c T/ ) + c - / - + -2 / -2 + + 2 / 2 + / + ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) So we hve T) = T/ ) + c - / - +... + 2 / 2 + / + ) For = log = T ) T c c T) = T) + c - / - +... + 2 / 2 + / + ) = c + c - / - +... + 2 / 2 + / + ) = c + c - / - +... + 2 / 2 + / + ) = c / + c - / - +... + 2 / 2 + / + ) = c / +... + 2 / 2 + / + ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) T ) So with = log T) = c / +... + 2 / 2 + / + ) Wht if =? T) = c + ) = clog + ) = log ) T c c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) T ) So with = log T) = c / +... + 2 / 2 + / + ) Wht if <? T c c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces exmple) T ) So with = log T) = c / +... + 2 / 2 + / + ) Wht if <? T c c Recll tht x + x - + + x + ) = x + -)/x-) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if <? Recll tht x + x - + + x + ) = x + -)/x-) So: ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if <? Recll tht x + x - + + x + ) = x + -)/x-) So: T) = c ) = ) ) c T c T Solvig Recurreces exmple)

Solvig Recurreces exmple) T ) So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T c c CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T) = c / ) ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T) = c / ) = c log / log ) = c log / ) ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T) = c / ) = c log / log ) = c log / ) recll logrithm fct: log = log ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T) = c / ) = c log / log ) = c log / ) recll logrithm fct: log = log = c log / ) = c log / ) ) c T c T Solvig Recurreces exmple)

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So with = log T) = c / +... + 2 / 2 + / + ) Wht if >? T) = c / ) = c log / log ) = c log / ) recll logrithm fct: log = log = c log / ) = c log / ) = log ) ) c T c T

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov So ) c T c T T log log ) Solvig Recurreces exmple)

The Mster Theorem Give: divide d coquer lgorithm A lgorithm tht divides the prolem of size ito suprolems, ech of size / Let the cost of ech stge i.e., the wor to divide the prolem + comie solved suprolems) e descried y the fuctio f) The, the Mster Theorem gives us coooo for the lgorithm s ruig time: CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov The Mster Theorem if T) = T/) + f) the W lrge for ) ) / AND ) ) ) ) log ) log log log log log c cf f f f O f f T

Usig The Mster Method T) = 9T/3) + =9, =3, f) = log = log 3 9 = 2 ) Sice f) = O log 3 9 - ), where =, cse pplies: T ) log log whe f ) O Thus the solutio is T) = 2 ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces The sustitutio method CLR 4.) A... the mig good guess method Guess the form of the swer, the use iductio to fid the costts d show tht solutio wors Exmples: T) = 2T/2) + ) T) = lg ) T) = 2T/2) +??? CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces The sustitutio method CLR 4.) A... the mig good guess method Guess the form of the swer, the use iductio to fid the costts d show tht solutio wors Exmples: T) = 2T/2) + ) T) = lg ) T) = 2T/2) + T) = lg ) T) = 2T/2 )+ 7) +??? CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov

Solvig Recurreces The sustitutio method CLR 4.) A... the mig good guess method Guess the form of the swer, the use iductio to fid the costts d show tht solutio wors Exmples: T) = 2T/2) + ) T) = lg ) T) = 2T/2) + T) = lg ) T) = 2T/2+ 7) + lg ) CS 447, Algorithms, Uiversity College Cor, Gregory M. Prov