09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

26 SUMS<br />

where A(n), B(n), and C(n) are the coefficients of dependence on the general<br />

parameters 01, B, and y.<br />

The repertoire method tells us to try plugging in simple functions of n<br />

<strong>for</strong> R,, hoping to find constant parameters 01, (3, and y where the solution is<br />

especially simple. Setting R, = 1 implies LX = 1, (3 = 0, y = 0; hence<br />

A(n) = 1.<br />

Setting R, = n implies a = 0, (3 = 1, y = 0; hence<br />

B(n) = n.<br />

Setting R, = n2 implies a = 0, (3 = -1, y = 2; hence<br />

2C(n) -B(n) = n2<br />

and we have C(n) = (n2 +n)/2. Easy as pie.<br />

There<strong>for</strong>e if we wish to evaluate<br />

n<br />

E( a + bk) ,<br />

k=O<br />

the sum-recurrence (2.6) boils down to (2.7) with a = (3 = a, y = b, and the<br />

answer is aA + aB(n) + bC(n) = a(n + 1) + b(n + l)n/2.<br />

Conversely, many recurrences can be reduced to sums; there<strong>for</strong>e the special<br />

methods <strong>for</strong> evaluating sums that we’ll be learning later in this chapter<br />

will help us solve recurrences that might otherwise be difficult. The Tower of<br />

Hanoi recurrence is a case in point:<br />

To = 0;<br />

T,, = 2T,_, +l , <strong>for</strong> n > 0.<br />

It can be put into the special <strong>for</strong>m (2.6) if we divide both sides by 2”:<br />

To/2' = 0;<br />

TJ2" = T,-,/2-' +l/2n, <strong>for</strong> n > 0.<br />

Now we can set S, = T,/2n, and we have<br />

so = 0;<br />

s, = s,~-’ +2-n) <strong>for</strong> n > 0.<br />

It follows that<br />

s, = t2-k<br />

k=l<br />

Actually easier; n =<br />

x 8<br />

nx 14n+1)14n+3) .

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

Saved successfully!

Ooh no, something went wrong!