Algorithms & Data Structures
Everything below this point in the knowledge base is about what the machine can do. This section is
Everything below this point in the knowledge base is about what the machine can do. This section is
Some structures cannot be made cheap on every single call, but can be made cheap *on average over any
Big-O describes an upper bound on growth. Saying an algorithm is $O(n^2)$ claims that beyond some
In practice you meet perhaps eight growth classes. Recognising which one a piece of code falls into —
Measuring an algorithm by timing it tells you about your laptop, your compiler, your input, and the
This page is a reference, not a tutorial — each numbered page in this section explains the reasoning
Most complexity analysis on this site asks how fast a known algorithm runs. This page asks a
A recursive algorithm's cost is itself defined recursively — mergesort's cost on n elements is twice its
Time complexity answers "how does the work grow?"; space complexity asks the same question about