Skip to content
ContentLora

    Tip: press / anywhere to search.

    Explainer

    Big O notation explained: how algorithm speed is measured

    Big O notation describes how the time or memory an algorithm needs grows with the size of its input, n: saying f(n) = O(g(n)) means f(n) stays below some constant multiple of g(n).[1] It is the shared language of algorithm research, and it explains why a better algorithm on a desktop computer can beat a worse one on a supercomputer once inputs get large.[2]

    Editor reviewedUpdated Explainer17 claims · 94% primaryComputing
    Reading level: 1 passage differs; the rest is the same for everyone.

    This page is a first step in our theory-of-computing reading order. Read it before complexity classes, which uses the same ideas to sort whole problems by difficulty, and before the matrix multiplication race, a live research problem stated in big O terms.

    Big O notation is how computer scientists say how fast an algorithm is without timing it on a particular machine. It describes how the time or memory needed grows as the problem size n, usually the number of items, gets larger.[1]

    What the notation says

    Writing f(n) = O(g(n)) means that, for big enough inputs, f(n) is less than some constant multiple of g(n).[1] A standard example: n² + 3n + 4 is O(n²), because once n is above 10 it is always smaller than 2n².[3] The small terms and the constant multiplier drop out, and only the fastest-growing part is left.

    Formally, f(n) = O(g(n)) means there are positive constants c and k with 0 ≤ f(n) ≤ c·g(n) for all n ≥ k, where c and k are fixed and do not depend on n.[4] Because big O is only an upper bound, 3n + 4 is also O(n²), strictly speaking.[3] Big Omega gives the matching lower bound, f(n) ≥ c·g(n) for large n, and big Theta gives a tight bound, within constant multiples on both sides.[5][6] People often write O when they mean Θ.[6]

    Common growth rates

    GrowthNameExample
    O(log n)logarithmicBinary search in a sorted list[7]
    O(n)linearLinear search, checking items one by one[8]
    O(n log n)“n log n”Merge sort; quicksort on typical inputs[9][10]
    O(n²)quadraticBubble sort on arbitrary data[11]
    O(n^k)polynomialAny algorithm bounded by a fixed power of n[12]
    exponentialexponentialTime bounded by an exponential function of n[13]

    Binary search works by repeatedly halving the part of a sorted list that could contain the target, which is why its running time grows only logarithmically.[7][14] Linear search checks items one at a time and, when the item is there, looks at about half the list on average.[8]

    Polynomial-time algorithms are broadly treated as reasonable to compute, while exponential ones grow too fast to expect exact answers in every case.[12] That line between polynomial and exponential is the starting point for complexity classes such as P and NP.

    Why growth rate beats hardware

    The point of big O is that a better growth rate eventually wins, whatever the hardware. NIST’s dictionary of algorithms gives the classic example: quicksort, O(n log n) on average, running on a small desktop computer can beat bubble sort, O(n²), running on a supercomputer. To sort a million numbers, quicksort takes about 20 million steps on average and bubble sort about a million million.[2]

    Worst case, typical case and the fine print

    An algorithm’s worst case is the input that forces it to use the most time or resources.[15] Quicksort shows why that matters: it takes Θ(n²) time in the worst case but is typically O(n log n), and a finely tuned quicksort beats most sorting algorithms in practice, including some with a better worst case.[10] Bubble sort is O(n²) in general but close to linear on a list that is already nearly sorted.[11]

    Every big O statement also assumes a model of computation and a resource being counted. That might be comparisons, item moves, floating-point multiplications, messages sent across a network, disk accesses, memory or elapsed time.[16] Big O hides constant factors, so two algorithms with the same growth rate can differ a lot in practice, and an algorithm with a better growth rate only wins once there are enough items.[4][10][2]

    Where this leads

    Big O is the language in which open research problems are stated. The race to multiply matrices faster, for example, is about lowering the exponent in the O(n^ω) cost of multiplying two n-by-n matrices.[17] Read how fast computers can multiply matrices for that story, and complexity classes for how computer scientists group problems by the best growth rate any algorithm could achieve.

    Next in the crash course

    Developing in AI & Computing

    Questions readers ask

    What does O(n) mean?

    It means the running time grows at most in proportion to the input size n, give or take a constant factor. Checking the items of a list one at a time, as linear search does, takes time proportional to n.[1][8]

    Is O(log n) faster than O(n)?

    For large inputs, yes. Binary search halves a sorted list at every step, so its running time grows only logarithmically with the number of items, while linear search grows in proportion to it.[7][8][14]

    What is the difference between big O, big Omega and big Theta?

    Big O is an upper bound (at most a constant multiple), big Omega a lower bound (at least a constant multiple), and big Theta a tight bound (within constant multiples above and below).[1][5][6]

    Does big O tell you how many seconds a program takes?

    No. It ignores constant factors and describes growth with input size, measured against a chosen model and resource, such as comparisons, disk accesses, memory or elapsed time.[4][16]

    Sources

    · 17 claims from 2 publishers

    Each numbered claim is a statement we checked against the sources listed with it. Tap a number in the text to see its sources in place.

    1. [1]

      NIST's Dictionary of Algorithms and Data Structures defines big-O notation as a theoretical measure of an algorithm's execution, usually the time or memory needed, given the problem size n; informally, f(n) = O(g(n)) means f(n) is less than some constant multiple of g(n). confirmedas of 2026-11-22

    2. [2]

      NIST illustrates why growth rates matter: quicksort, O(n log n) on average, running on a small desktop computer can beat bubble sort, O(n²), on a supercomputer; sorting 1,000,000 numbers takes quicksort about 20,000,000 steps on average and bubble sort 1,000,000,000,000 steps. confirmedas of 2026-11-22

    3. [3]

      NIST's example is that n² + 3n + 4 is O(n²), because it is less than 2n² for every n above 10; big-O is an upper bound, so 3n + 4 is also strictly O(n²). confirmedas of 2026-11-22

    4. [4]

      Formally, f(n) = O(g(n)) means there are positive constants c and k such that f(n) is at most c times g(n) for every n of at least k, with c and k fixed and not depending on n. confirmedas of 2026-11-22

    5. [5]

      Big Omega is the matching lower bound: informally, f(n) = Ω(g(n)) means f(n) is more than some constant multiple of g(n). confirmedas of 2026-11-22

    6. [6]

      NIST notes that big-O is often misused to mean "equal to" rather than "less than"; the tight "within a constant multiple" relationship is written with Theta, f(n) = Θ(g(n)). confirmedas of 2026-11-22

    7. [9]

      Merge sort splits the items into two groups, recursively sorts each group and merges them, with a run time of Θ(n log n). confirmedas of 2026-11-22

    8. [10]

      Quicksort takes Θ(n²) time in the worst case but is typically O(n log n), and NIST notes that a finely tuned quicksort beats most sorting algorithms in practice, including some whose worst case is O(n log n). confirmedas of 2026-11-22

    9. [11]

      Bubble sort repeatedly swaps adjacent items that are out of order; its complexity is O(n²) for arbitrary data but approaches Θ(n) when the list is nearly sorted. confirmedas of 2026-11-22

    10. [12]

      Polynomial time means the execution time is at most a polynomial in the problem size, O(n^k) for a constant k; NIST says such algorithms are broadly reasonable to compute, while exponential algorithms grow too fast to expect exact solutions in all cases. confirmedas of 2026-11-22

    11. [13]

      In complexity theory, exponential means the time or memory a computation needs is bounded by an exponential function of the problem size n. confirmedas of 2026-11-22

    12. [14]

      In complexity theory, logarithmic means a computation's time or memory is bounded by a logarithmic function of the problem size, O(log n). confirmedas of 2026-11-22

    13. [15]

      The worst case is the situation or input that forces an algorithm or data structure to take the most time or resources. confirmedas of 2026-11-22

    14. [16]

      Any such measure refers to a model of computation and a limiting resource, which may be floating-point multiplications, messages passed across a network, comparisons, item moves, disk accesses, memory used or elapsed time. confirmedas of 2026-11-22

    15. [17]

      Researchers measure the cost of matrix multiplication by the exponent omega (ω), the smallest number such that two n-by-n matrices can be multiplied using about n^ω arithmetic operations (strictly, O(n^(ω+ε)) for every ε > 0). reportedas of 2026-11-22

    Revision history (1)
    1. Page created.

    Created Nov 22, 2026. Last reviewed by an editor on Nov 22, 2026. Next scheduled review: Aug 16, 2027.

    Cite this page

    "Big O notation explained: how algorithm speed is measured." ContentLora, updated Nov 22, 2026. https://contentlora.com/explain/big-o-notation-explained

    Spotted an error? Suggest a correction or emailcorrections@contentlora.com.