Big O Notation

903 Words2 Pages

Big O notation or Big Oh notation, and also Landau notation or asymptotic notation, is a mathematical notation used to describe the asymptotic behavior of functions. (Sestoft, p. 40) Its purpose is to characterize a function's behavior for very large (or very small) inputs in a simple but rigorous way that enables comparison to other functions. More precisely, the symbol O is used to describe an asymptotic upper bound for the magnitude of a function in terms of another, usually simpler, function. It has two main areas of application in mathematics, it is usually used to characterize the residual term of a truncated infinite series, especially an asymptotic series, and in computer science, it is useful in the analysis of the complexity of algorithms.

Big-O Notation is short for order of growth notation. It is defined as given two function t(n) and g(n), we say that t(n) = O(g(n)) if there exist a positive constant A and some number N such that t(n) <= A g(n) for all n > n T(n) means the running time of the algorithm on a problem of size N. (Sestoft, p. 105) Big-O basically means that t(n) asymptotically (only for large n) grows not faster than g(n) (give or take a constant factor). The order of growth of t(n) is not larger than g(n).

When put in terms of order of growth, f = O(g) is like "f <= g." When two searching algorithms are compared, both the worst and average time is O(n) for a sequential search and O(log2 n) for the binary search. (Sestoft, p. 110)

Big-O notation is concerned with what happens for very large values of N, therefore only the largest term in a polynomial is needed. All smaller terms are dropped.

For example, the number of operations in some sorts is N2 - N. For large values of N, the single N term is insignificant compared to N2, therefore one of these sorts would be described as an O(N2) algorithm. (Sestoft, p. 80)

Similarly, constant multipliers are ignored. So a O(4*N) algorithm is equivalent to O(N), which is how it should be written. Ultimately you want to pay attention to these multipliers in determining the performance, but for the first round of analysis using Big-O, you simply ignore constant factors.

Complexity analysis can be very useful, but there are problems with it too. Many algorithms are simply too hard to analyze mathematically.

More about Big O Notation

Open Document