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.

“It is obvious that<br />

the sign = is really<br />

the wrong sign<br />

<strong>for</strong> such relations,<br />

because it suggests<br />

symmetry, and<br />

there is no such<br />

symmetry. . . .<br />

Once this warning<br />

has been given,<br />

there is, however,<br />

not much harm in<br />

using the sign = ,<br />

and we shall maintain<br />

it, <strong>for</strong> no other<br />

reason than that it<br />

is customary.”<br />

-N. G. de Bruijn /62]<br />

[Now is a good<br />

time to do warmup<br />

exercises 3 and 4.)<br />

9.2 0 NOTATION 433<br />

And in English, this ‘is’ is one-way. We say that a bird is an animal, but we<br />

don’t say that an animal is a bird; “animal” is a crudification of “bird!’<br />

Fourth, <strong>for</strong> our purposes it’s natural. If we limited our use of O-notation<br />

to situations where it occupies the whole right side of a <strong>for</strong>mula-as in the<br />

harmonic number approximation H, = O(log n), or as in the description of<br />

a sorting algorithm’s running time T(n) = O(nlogn) -it wouldn’t matter<br />

whether we used ‘=’ or something else. But when we use O-notation in the<br />

middle of an expression, as we usually do in asymptotic calculations, our<br />

intuition is well satisfied if we think of the equals sign as an equality, and if<br />

we think of something like 0 (1 /n) as a very small quantity.<br />

So we’ll continue to use ‘=I, and we’ll continue to regard O(g(n)) as an<br />

incompletely specified function, knowing that we can always fall back on the<br />

set-theoretic definition if we must.<br />

But we ought to mention one more technicality while we’re picking nits<br />

about definitions: If there are several variables in the environment, O-notation<br />

<strong>for</strong>mally represents sets of functions of two or more variables, not just one.<br />

The domain of each function is every variable that is currently “free” to vary.<br />

This concept can be a bit subtle, because a variable might be defined only<br />

in parts of an expression, when it’s controlled by a x or something similar.<br />

For example, let’s look closely at the equation<br />

f (k’ + O(k)) = in3 + O(n2), integer n > 0. (9.16)<br />

k=O<br />

The expression k2 + O(k) on the left stands <strong>for</strong> the set of all two-variable<br />

functions of the <strong>for</strong>m k2 + f(k,n) such that there exists a constant C with<br />

]f(k, n)l $ Ck <strong>for</strong> 0 < k 6 n. The sum of this set of functions, <strong>for</strong> 0 6 k < n,<br />

is the set of all functions g(n) of the <strong>for</strong>m<br />

$(k’+f(k,n)) = ~n3+~n2+~n+f(0,n)+f(l,n)+...+f(n,n),<br />

k=O<br />

where f has the stated property. Since we have<br />

(~n2+~n+f(0,n)+f(l,n)+...+f(n,n)l<br />

< ~n2+/7n2+C.0+C.l +...+C.n<br />

< n2 + Cl,n2 + n)/2 < (C + l)n2 ,<br />

all such functions g(n) belong to the right-hand side of (9.16); there<strong>for</strong>e (9.16)<br />

is true.<br />

People sometimes abuse O-notation by assuming that it gives an exact<br />

order of growth; they use it as if it specifies a lower bound as well as an<br />

upper bound. For ex.ample, an algorithm to sort n numbers might be called

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

Saved successfully!

Ooh no, something went wrong!