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.

470 Chap. 14 <strong>Analysis</strong> TechniquesIf we continue for more terms, the r<strong>at</strong>io appears to converge on a valueslightly gre<strong>at</strong>er then 1.618. Assuming f(n)/f(n − 1) really does convergeto a fixed value as n grows, we can determine wh<strong>at</strong> th<strong>at</strong> value must be.f(n) f(n − 1) f(n − 2)= +f(n − 2) f(n − 2) f(n − 2) → x + 1For some value x. This follows from the fact th<strong>at</strong> f(n) = f(n − 1) +f(n − 2). We divide by f(n − 2) to make the second term go away, <strong>and</strong>we also get something useful in the first term. Remember th<strong>at</strong> the goal ofsuch manipul<strong>at</strong>ions is to give us an equ<strong>at</strong>ion th<strong>at</strong> rel<strong>at</strong>es f(n) to somethingwithout recursive calls.For large n, we also observe th<strong>at</strong>:f(n)f(n − 2) =f(n) f(n − 1)f(n − 1) f(n − 2) → x2as n gets big. This comes from multiplying f(n)/f(n − 2) by f(n −1)/f(n − 1) <strong>and</strong> rearranging.If x exists, then x 2 − x − 1 → 0. Using the quadr<strong>at</strong>ic equ<strong>at</strong>ion, the onlysolution gre<strong>at</strong>er than one isx = 1 + √ 52≈ 1.618.This expression also has the name φ. Wh<strong>at</strong> does this say about the growthr<strong>at</strong>e of the Fibonacci sequence? It is exponential, with f(n) = Θ(φ n ).More precisely, f(n) converges toφ n − (1 − φ) n√5.14.2.2 Exp<strong>and</strong>ing RecurrencesEstim<strong>at</strong>ing bounds is effective if you only need an approxim<strong>at</strong>ion to the answer.More precise techniques are required to find an exact solution. One approach iscalled exp<strong>and</strong>ing the recurrence. In this method, the smaller terms on the rightside of the equ<strong>at</strong>ion are in turn replaced by their definition. This is the exp<strong>and</strong>ingstep. These terms are again exp<strong>and</strong>ed, <strong>and</strong> so on, until a full series with no recurrenceresults. This yields a summ<strong>at</strong>ion, <strong>and</strong> techniques for solving summ<strong>at</strong>ions canthen be used. A couple of simple expansions were shown in Section 2.4. A morecomplex example is given below.

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

Saved successfully!

Ooh no, something went wrong!