Big-O notation describes the upper bound on the growth rate of a function. When we say an algorithm runs in time, we mean that as the input size grows large, the number of operations is bounded above by a constant times . We deliberately ignore constant factors and lower-order terms because they become negligible at scale.
Why we use it
Algorithms that look fast on small inputs can be catastrophically slow at scale. A function that visits every pair of items does work; at that is operations — roughly an hour on a fast CPU. Compare this to , which finishes the same input in seconds.
Formal definition
We write when there exist positive constants and such that for all , . The notation captures an asymptotic ceiling — actual runtime can be lower for any fixed input.
Reading Big-O in practice
When you see written, treat it as — only the dominant term matters. Coefficients are dropped: is just . Logarithms of any constant base collapse to the same class because they differ only by a multiplicative constant.
Variants
, , and describe upper, lower, and tight bounds respectively. In casual interview talk people use "Big-O" to mean "tight bound" even though formally that's .