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.

434 ASYMPTOTICS<br />

inefficient “because its running time is O(n2)!’ But a running time of 0 (nL)<br />

does not imply that the rrrnning time is not also O(n). There’s another<br />

notation, Big Omega, <strong>for</strong> lower bounds:<br />

f(n) = fl(gin)) W If(n)1 3 Clg(nil <strong>for</strong> some C > 0. (9.17)<br />

We have f(n) = fI(g(n)) if and only if g(n) = O(f(n)). A sorting algorithm<br />

whose running time is n( n’ ) is inefficient compared with one whose running<br />

time is 0 (n log n) , if n is large enough.<br />

Finally there’s Big Theta, which specifies an exact order of growth: Since 0 and 0 are<br />

f(n) = O(g(n))<br />

‘In) = o(g(n)) w and f(n) = n(g(n)) .<br />

umercase Greek<br />

It%ers, the 0 in<br />

(9.18) O-notation must<br />

be a capital Greek<br />

We have f(n) = @(g(n)) if 0.<br />

This is essentially the relation f(n.) + g(n) of (9.8). We also have<br />

(9.19)<br />

f(n) - 4(n) W f(n) = s(n) +0(64(n)). (9.20)<br />

Many authors use ‘0’ in asymptotic <strong>for</strong>mulas, but a more explicit ‘0’ expression<br />

is almost always preferable. For example, the average running time<br />

of a <strong>computer</strong> method called. “bubblesort” depends on the asymptotic value<br />

of the sum P(n) = ,YF=, kn k kl/n’. . . Elementary asymptotic methods suffice<br />

to prove that P(n) N m?!, which means that the ratio P(n)/a approaches<br />

1 as n t co. However, the true behavior of P(n) is best understood<br />

by considering the d@eerence, P(n) - J7cn/2, not the ratio:<br />

n ( P(nllJ7m72 1 P(n) - &G<br />

1 0.798 -0.253<br />

10 0.878 -0.484<br />

20 0.904 -0.538<br />

30 0.918 -0.561<br />

40 0.927 -0.575<br />

50 0.934 -0.585<br />

The numerical evidence in the middle column is not very compelling; it certainly<br />

is far from a dramatic proof that P(n)/- approaches 1 rapidly,

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

Saved successfully!

Ooh no, something went wrong!