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.

[The value of s1<br />

cancels out, so it<br />

can be anything<br />

but zero.)<br />

2.2 SUMS AND RECURRENCES 27<br />

(Notice that we’ve left the term <strong>for</strong> k = 0 out of this sum.) The sum of the<br />

geometricseries2~‘+2~2+~~~+2~“=(~)’+(~)2+~~~+(~)nwillbederived<br />

later in this chapter; it turns out to be 1 - (i )“. Hence T,, = 2”S, = 2” - 1.<br />

We have converted T, to S, in this derivation by noticing that the recurrence<br />

could be divided by 2n. This trick is a special case of a general<br />

technique that can reduce virtually any recurrence of the <strong>for</strong>m<br />

a,T,, = bnTn-1 + cn (2.9)<br />

to a sum. The idea is to multiply both sides by a summation factor, s,:<br />

s,a,T,, = s,,bnTn-1 + snc,, .<br />

This factor s, is cleverly chosen to make<br />

s b<br />

n n =h-1 an-l s<br />

Then if we write S, = s,a,T,, we have a sum-recurrence,<br />

Hence<br />

Sn = Sn-1 +SnCn.<br />

%I = socuT + t skck = s.lblTo + c skck ,<br />

k=l k=l<br />

and the solution to the original recurrence (2.9) is<br />

1<br />

T, = -<br />

ha,<br />

n<br />

s,b,To + &Ck<br />

k=l<br />

(2.10)<br />

For example, when n = 1 we get T, = (s~b,To +slcl)/slal = (b,To +cl)/al.<br />

But how can we be clever enough to find the right s,? No problem: The<br />

relation s,, = snPl anPI /b, can be unfolded to tell us that the fraction<br />

a,- 1 a,-2.. . al<br />

S<br />

n = b,bnp,...bz ’<br />

(2.11)<br />

or any convenient constant multiple of this value, will be a suitable summation<br />

factor. For example, the Tower of Hanoi recurrence has a,, = 1 and b, = 2;<br />

the general method we’ve just derived says that sn = 2-” is a good thing to<br />

multiply by, if we want to reduce the recurrence to a sum. We don’t need a<br />

brilliant flash of inspiration to discover this multiplier.<br />

We must be careful, as always, not to divide by zero. The summationfactor<br />

method works whenever all the a’s and all the b’s are nonzero.

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

Saved successfully!

Ooh no, something went wrong!