Skip to content
StackDecode

Big-O Cheat Sheet

Time and space complexity of data structures, sorting and graph algorithms, colour-coded and filterable.

NeweasyRuns in your browser

How it works

Big-O describes how an algorithm’s work or memory grows as the input size n grows, ignoring constants. It is an upper bound: “at most this fast-growing”.

  • Best / average / worst: the cost on the luckiest input, a typical input, and the most hostile input.
  • Amortised cost averages a rare expensive operation over many cheap ones (appending to a dynamic array).
  • Stable sorts keep equal elements in their original order, which matters when sorting by multiple keys.
  • For graphs, V is the number of vertices and E the number of edges.
  • Colours rank growth from excellent (constant) to horrible (exponential). The complexity text is always shown, so colour is never the only signal.
  • Real performance also depends on constants, cache behaviour and input shape; Big-O says how it scales, not which is faster at small n.