core Estimated learning time: 12 h

P-5.1 Measuring Cost, and What Big-O Hides

You can derive the growth rate of a piece of code, compare two algorithms by it, and state the three things the notation deliberately throws away.

Growth-rate notation is the common language for comparing algorithms and it is routinely over-trusted. It discards constants, ignores small inputs and says nothing about memory or cache behaviour, all of which can decide a real contest between two implementations. Learn to derive it confidently and to remember what it left out, because both halves are needed to make a decision anyone should act on.

Work through these

  • Counting operations as a function of input size

    Start by asking how many times the innermost work happens when the input has size n. Nested loops multiply, sequential loops add, and that accounting is the whole technique.

    MIT OpenCourseWare 6.006: Introduction to Algorithms · Course
  • The common growth rates, in order, and what each feels like

    Constant, logarithmic, linear, linear times logarithmic, quadratic and exponential is the ladder nearly everything sits on. Knowing where a rate lands tells you what input size becomes impossible.

  • Worst case, average case and best case are different questions

    Quicksort is quadratic at worst and fast in practice; hash lookup is constant on average and linear at worst. Stating which case you mean is part of stating the result.

  • What the notation throws away: constants, small inputs, memory

    Two algorithms with the same growth rate can differ tenfold in real time, and for small inputs the worse rate often wins. Memory use and cache behaviour do not appear in the notation at all.

  • Measure two implementations and compare against your prediction

    Time both across a range of input sizes and plot what you get. Where measurement disagrees with the analysis, the disagreement is the interesting finding rather than an embarrassment.

Sign in to keep your progress.

Free resources

Links last checked 31 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.