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

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

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

Looks like Greek<br />

to me.<br />

J(n) = n/2, beginning as follows:<br />

1.3 THE JOSEPHUS PROBLEM 13<br />

m 1 n=2m+l J(n) = 21f 1 = n/2 n (binary)<br />

1 0 2 1 10<br />

3 2 10 5 1010<br />

5 10 42 21 101010<br />

7 42 170 85 10101010<br />

Notice the pattern in the rightmost column. These are the binary numbers<br />

<strong>for</strong> which cyclic-shifting one place left produces the same result as ordinaryshifting<br />

one place right (halving).<br />

OK, we understand the J function pretty well; the next step is to generalize<br />

it. What would have happened if our problem had produced a recurrence<br />

that was something like (1.8), but with different constants? Then we might<br />

not have been lucky enough to guess the solution, because the solution might<br />

have been really weird. Let’s investigate’this by introducing constants a, 6,<br />

and y and trying to find a closed <strong>for</strong>m <strong>for</strong> the more general recurrence<br />

f(1) = cc;<br />

f(2n) = 2f(n) + fi, <strong>for</strong> n 3 1; (1.11)<br />

f(2n+1)=2f(n)+y, <strong>for</strong> n 3 1.<br />

(Our original recurrence had a = 1, fi = -1, and y = 1.) Starting with<br />

f (1) = a and working our way up, we can construct the following general<br />

table <strong>for</strong> small values of n:<br />

n f(n)<br />

l a<br />

2 2a-f 6<br />

3201 +y<br />

4 4af3f3<br />

5 4a+28+ y<br />

6 4a+ fi+2y<br />

7 4a + 3Y<br />

8 8a+7p<br />

9 8a+ 6fl + y<br />

(1.12)<br />

It seems that a’s coefficient is n’s largest power of 2. Furthermore, between<br />

powers of 2, 0’s coefficient decreases by 1 down to 0 and y’s increases by 1<br />

up from 0. There<strong>for</strong>e if we express f(n) in the <strong>for</strong>m<br />

f(n) = A(n) a + B(n) B + C(n)y , (1.13)

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

Saved successfully!

Ooh no, something went wrong!