Big O notation is a mathematical notation used to describe the limiting behavior of a function when the argument tends toward a particular value or infinity. In computer science, it is most commonly employed to characterize the asymptotic upper bound of an algorithm’s running time or space requirements as a function of the size of its input, denoted $n$.
Formal definition
Let $f(n)$ and $g(n)$ be functions mapping positive integers to non‑negative real numbers. The statement
$$ f(n) = O(g(n)) $$
means that there exist positive constants $c$ and $n_{0}$ such that
$$ 0 \le f(n) \le c , g(n) \qquad \text{for all } n \ge n_{0}. $$
Thus, $f(n)$ does not grow faster than a constant multiple of $g(n)$ beyond some threshold.
Historical background
The notation originates from the work of German mathematicians Paul Bachmann (1894) and Edmund Landau (1909), who introduced it as part of the “Landau symbols” to classify the growth rates of functions in analytic number theory. The computer‑science community adopted the notation in the mid‑20th century for algorithm analysis.
Common classes
Typical complexity classes expressed with Big O include:
- $O(1)$ – constant time
- $O(\log n)$ – logarithmic time
- $O(n)$ – linear time
- $O(n \log n)$ – linearithmic time
- $O(n^{2})$ – quadratic time
- $O(2^{n})$ – exponential time
Related notations
Big O is part of a family of asymptotic symbols:
- Θ (Theta) – tight bound: $f(n) = Θ(g(n))$ when $f(n) = O(g(n))$ and $f(n) = Ω(g(n))$.
- Ω (Omega) – lower bound: $f(n) = Ω(g(n))$ if there exist $c > 0$ and $n_{0}$ such that $f(n) \ge c,g(n)$ for all $n \ge n_{0}$.
- o (little‑o) – non‑tight upper bound: $f(n) = o(g(n))$ if for every $c > 0$ there exists an $n_{0}$ with $f(n) < c,g(n)$ beyond $n_{0}$.
- ω (little‑omega) – non‑tight lower bound: analogous to little‑o.
Usage in algorithm analysis
When evaluating an algorithm, practitioners identify the dominant term of its running‑time expression, discard lower‑order terms and constant factors, and express the result using Big O. This abstraction enables comparison of algorithms independent of hardware, implementation details, or small input sizes.
Limitations
Big O provides only an upper bound and does not convey average‑case performance, constant factors, or behavior on small inputs. Consequently, complementary analysis (e.g., empirical benchmarking, amortized analysis) is often required for practical performance assessment.
References
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press.
- Knuth, D. E. (1976). The Art of Computer Programming, Volume 1: Fundamental Algorithms (2nd ed.). Addison‑Wesley.
- Landau, E. (1909). Handbuch der Lehre von der Verteilung der Primzahlen. Teubner.