23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

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 Log-Star <strong>and</strong> Inverse Ackermann Functions<br />

A surpris<strong>in</strong>g property of the tree-based partition data structure, when implemented<br />

us<strong>in</strong>g the union-by-size <strong>and</strong> path-compression heuristics, is that perform<strong>in</strong>g a<br />

series of nunion <strong>and</strong> f<strong>in</strong>d operations takes 0(nlog*n) time, where log*n is the<br />

log-star function, which is the <strong>in</strong>verse of the tower-of-twos function. Intuitively,<br />

log*n is the number of times that one can iteratively take the logarithm (base 2) of<br />

a number before gett<strong>in</strong>g a number smaller than 2. Table 11.1 shows a few sample<br />

values.<br />

Table 11.1: Some values of log* n <strong>and</strong> critical values<br />

for its <strong>in</strong>verse.<br />

As is demonstrated <strong>in</strong> Table 11.1, for all practical purposes, log* n ≤ 5. It is an<br />

amaz<strong>in</strong>gly slow-grow<strong>in</strong>g function (but one that is grow<strong>in</strong>g nonetheless).<br />

In fact, the runn<strong>in</strong>g time of a series of n partition operations implemented as<br />

above can actually be shown to be O(nα(n)), where α(n) is the <strong>in</strong>verse of the<br />

Ackermann function,A, which grows asymptotically even slower than log* n.<br />

Although we will not prove this fact, let us def<strong>in</strong>e the Ackermann function here,<br />

so as to appreciate just how quickly it grows; hence, how slowly its <strong>in</strong>verse<br />

grows. We first def<strong>in</strong>e an <strong>in</strong>dexed Ackermann function, Ai, as follows:<br />

A 0 (n)= 2n<br />

for n≥0<br />

725

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

Saved successfully!

Ooh no, something went wrong!