(definition)
Definition: A theoretical measure of the execution of an algorithm, usually the time or memory needed, given the problem size n, which is usually the number of items. Informally, saying some equation f(n) = O(g(n)) means it is less than some constant multiple of g(n). The notation is read, "f of n is big oh of g of n".
Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0
f(n)
cg(n) for all n
k. The values of c and k must be fixed for the function f and must not depend on n.
Also known as O.
See also
(n),
(n),
(n),
, little-o notation, asymptotic upper bound, asymptotically tight bound, NP, complexity, model of computation.
Note:
As an example, n2 + 3n + 4 is O(n2), since n2 + 3n + 4 < 2n2 for all n > 10. Strictly speaking, 3n + 4 is O(n2), too, but big-O notation is often misused to mean equal to rather than less than. The notion of "equal to" is expressed by
(n).
The importance of this measure can be seen in trying to decide whether an algorithm is adequate, but may just need a better implementation, or the algorithm will always be too slow on a big enough input. For instance, quicksort, which is O(n log n) on average, running on a small desktop computer can beat bubble sort, which is O(n2), running on a supercomputer if there are a lot of numbers to sort. To sort 1,000,000 numbers, the quicksort takes 6,000,000 steps on average, while the bubble sort takes 1,000,000,000,000 steps!
Any measure of execution must implicitly or explicitly refer to some computation model. Usually this is some notion of the limiting factor. For one problem or machine, the number of floating point multiplications may be the limiting factor, while for another, it may be the number of messages passed across a network. Other measures which may be important are compares, item moves, disk accesses, memory used, or elapsed ("wall clock") time.
Strictly, the character is the upper-case Greek letter Omicron, not the letter O, but who can tell the difference?
Author: PEB
If you have suggestions, corrections, or comments, please get in touch with Paul E. Black (paul.black@nist.gov).
Entry modified Thu Jan 17 10:03:49 2002.
HTML page formatted Thu Jan 31 13:48:12 2002.
This page's original URL is http://www.nist.gov/dads/HTML/bigOnotation.html