25.11.2014 Views

Algorithms and Data Structures

Algorithms and Data Structures

Algorithms and Data Structures

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.

N.Wirth. <strong>Algorithms</strong> <strong>and</strong> <strong>Data</strong> <strong>Structures</strong>. Oberon version 87<br />

f i+1 = f i + f i-1 , f 1 = 1, f 0 = 0<br />

These are the recursive rules (or recurrence relations) defining the Fibonacci numbers:<br />

f = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...<br />

Each Fibonacci number is the sum of its two predecessors. As a consequence, the numbers of initial runs<br />

on the two input sequences must be two consecutive Fibonacci numbers in order to make Polyphase work<br />

properly with three sequences.<br />

How about the second example (Table 2.14) with six sequences? The formation rules are easily derived<br />

as<br />

a 4 (L+1) = a 0 (L)<br />

a 3 (L+1) = a 0 (L) + a 4 (L)<br />

a 2 (L+1) = a 0 (L) + a 3 (L)<br />

a 1 (L+1) = a 0 (L) + a 2 (L)<br />

a 0 (L+1) = a 0 (L) + a 1 (L)<br />

= a 0 (L) + a 0 (L-1)<br />

= a 0 (L) + a 0 (L-1) + a 0 (L-2)<br />

= a 0 (L) + a 0 (L-1) + a 0 (L-2) + a 0 (L-3)<br />

= a 0 (L) + a 0 (L-1) + a 0 (L-2) + a 0 (L-3) + a 0 (L-4)<br />

Substituting f i for a 0 (i) yields<br />

f i+1 = f i + f i-1 + f i-2 + f i-3 + f i-4 for i > 4<br />

f 4 = 1<br />

f i = 0 for i < 4<br />

These numbers are the Fibonacci numbers of order 4. In general, the Fibonacci numbers of order p are<br />

defined as follows:<br />

f i+1 (p) = f i (p) + fi-1(p) + ... + f i-p (p) for i > p<br />

f p (p) = 1<br />

f i (p) = 0 for 0 ≤ i < p<br />

Note that the ordinary Fibonacci numbers are those of order 1.<br />

We have now seen that the initial numbers of runs for a perfect Polyphase Sort with N sequences are the<br />

sums of any N-1, N-2, ... , 1 (see Table 2.15) consecutive Fibonacci numbers of order N-2.<br />

L \ N: 3 4 5 6 7 8<br />

1 2 3 4 5 6 7<br />

2 3 5 7 9 11 13<br />

3 5 9 13 17 21 25<br />

4 8 17 25 33 41 49<br />

5 13 31 49 65 81 97<br />

6 21 57 94 129 161 193<br />

7 34 105 181 253 321 385<br />

8 55 193 349 497 636 769<br />

9 89 355 673 977 1261 1531<br />

10 144 653 1297 1921 2501 3049<br />

11 233 1201 2500 3777 4961 6073<br />

12 377 2209 4819 7425 9841 12097<br />

13 610 4063 9289 14597 19521 24097<br />

14 987 7473 17905 28697 38721 48001

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

Saved successfully!

Ooh no, something went wrong!