11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sec. 14.2 Recurrence Rel<strong>at</strong>ions 473Note th<strong>at</strong>= a m T(1) + a m−1 c(n/b m−1 ) k + · · · + ac(n/b) k + cn k= a m c + a m−1 c(n/b m−1 ) k + · · · + ac(n/b) k + cn km∑= c a m−i b iki=0∑m= ca m (b k /a) i .i=0a m = a log b n = n log b a . (14.1)The summ<strong>at</strong>ion is a geometric series whose sum depends on the r<strong>at</strong>io r = b k /a.There are three cases.1. r < 1. From Equ<strong>at</strong>ion 2.4,Thus,m∑r i < 1/(1 − r), a constant.i=0T(n) = Θ(a m ) = Θ(n log ba ).2. r = 1. Because r = b k /a, we know th<strong>at</strong> a = b k . From the definitionof logarithms it follows immedi<strong>at</strong>ely th<strong>at</strong> k = log b a. We also note fromEqu<strong>at</strong>ion 14.1 th<strong>at</strong> m = log b n. Thus,m∑r = m + 1 = log b n + 1.i=0Because a m = n log b a = n k , we have3. r > 1. From Equ<strong>at</strong>ion 2.5,T(n) = Θ(n log b a log n) = Θ(n k log n).Thus,m∑i=0r = rm+1 − 1r − 1= Θ(r m ).T(n) = Θ(a m r m ) = Θ(a m (b k /a) m ) = Θ(b km ) = Θ(n k ).We can summarize the above deriv<strong>at</strong>ion as the following theorem, sometimesreferred to as the Master Theorem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!