18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

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.

<strong>The</strong> Big Oh Notation<br />

Next: Growth Rates Up: Introduction to <strong>Algorithm</strong>s Previous: BestWorst, and Average-Case<br />

<strong>The</strong> Big Oh Notation<br />

We have agreed that the best, worst, and average-case complexities of a given algorithm are numerical<br />

functions of the size of the instances. However, it is difficult to work with these functions exactly<br />

because they are often very complicated, with many little up and down bumps, as shown in Figure .<br />

Thus it is usually cleaner and easier to talk about upper and lower bounds of such functions. This is<br />

where the big Oh notation comes into the picture.<br />

Figure: Upper and lower bounds smooth out the behavior of complex functions<br />

We seek this smoothing in order to ignore levels of detail that do not impact our comparison of<br />

algorithms. Since running our algorithm on a machine that is twice as fast will cut the running times of<br />

all algorithms by a multiplicative constant of two, such constant factors would be washed away in<br />

upgrading machines. On the RAM we ignore such constant factors anyway and therefore might as well<br />

ignore them when comparing two algorithms. We use the following notation:<br />

● f(n) = O(g(n)) means is an upper bound on f(n). Thus there exists some constant c such that<br />

f(n) is always , for large enough n.<br />

● means is a lower bound on f(n). Thus there exists some constant c such that<br />

f(n) is always , for large enough n.<br />

● means is an upper bound on f(n) and is a lower bound on f(n), for<br />

large enough n. Thus there exists constants and such that and .<br />

This means that g(n) is a nice, tight bound on f(n).<br />

file:///E|/BOOK/BOOK/NODE14.HTM (1 of 2) [19/1/2003 1:28:11]

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

Saved successfully!

Ooh no, something went wrong!