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.

Beware: The authors<br />

are expecting<br />

us to figure out<br />

the idea of the<br />

repertoire method<br />

from seat-of-thepants<br />

examples,<br />

instead of giving<br />

us a top-down<br />

presentation. The<br />

method works best<br />

with recurrences<br />

that are ‘linear” in<br />

the sense that /heir<br />

solutions can be<br />

expressed as a sum<br />

of arbitrary parameters<br />

multiplied by<br />

functions of n, as<br />

in (1.13). Equation<br />

(1.13) is the key.<br />

(‘relax = ‘destroy’)<br />

I think I get it:<br />

The binary representations<br />

of A(n),<br />

B(n), and C(n)<br />

have 1 ‘s in different<br />

positions.<br />

1.3 THE JOSEPHUS PROBLEM 15<br />

Our conjectures in (1.14) follow immediately, since we can solve these equations<br />

to get C(n) = n - A(n) = 1 and B(n) = A(n) - 1 - C(n) = 2” - 1 - 1.<br />

This approach illustrates a surprisingly useful repertoire method <strong>for</strong> solving<br />

recurrences. First we find settings of general parameters <strong>for</strong> which we<br />

know the solution; this gives us a repertoire of special cases that we can solve.<br />

Then we obtain the general case by combining the special cases. We need as<br />

many independent special solutions as there are independent parameters (in<br />

this case three, <strong>for</strong> 01, J3, and y). Exercises 16 and 20 provide further examples<br />

of the repertoire approach.<br />

We know that the original J-recurrence has a magical solution, in binary:<br />

J(bn bm-1 . . . bl bob) = (bm-1 . . . b, bo b,)z ,<br />

where b, = 1.<br />

Does the generalized Josephus recurrence admit of such magic?<br />

Sure, why not? We can rewrite the generalized recurrence (1.11) as<br />

f(1) = a;<br />

f(2n + j) = 2f(n) + J3j , <strong>for</strong> j = 0,l and n 3 1,<br />

if we let BO = J3 and J31 = y. And this recurrence unfolds, binary-wise:<br />

f(bnbm-1 . . . bl bob) = 2f((bm b-1 . . . b, 12) + fib0<br />

= 4f((b, b,el . . . Wz) + 2f’b, + fib‘,<br />

(1.15)<br />

= 2mf((bmh) +2m-1Pbmm, +.“+@b, + (3bo<br />

= 2”(x + 293b,m, + “’ + 2(&q + &, .<br />

Suppose we now relax the radix 2 notation to allow arbitrary digits instead<br />

of just 0 and 1. The derivation above tells us that<br />

f((bm b-1 . . bl bob) = (01 fib,-, Pb,,mz . . . @b, f’bo 12 .<br />

(1.16)<br />

Nice. We would have seen this pattern earlier if we had written (1.12) in<br />

anot her way:

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

Saved successfully!

Ooh no, something went wrong!