Home › Interview & Career › Big-O Cheat Sheet & Quiz

Big-O Cheat Sheet & Complexity Quiz

Time and space complexity of arrays, linked lists, hash maps, trees, heaps, graphs, sorting and searching algorithms in one colour-coded table. Compare growth rates on an interactive chart and test yourself with 30 coding-interview Big-O questions.

Data structure operations

What Big-O means

Big-O describes how the running time (or memory) of an algorithm grows as the input size n grows, ignoring constants and smaller terms. O(n) means doubling the input roughly doubles the work; O(n²) means it quadruples; O(log n) means doubling the input adds just one more step.

Quick rules for interviews

  • Drop constants: O(2n) → O(n). Drop smaller terms: O(n² + n) → O(n²).
  • Sequential steps add (O(a + b)); nested loops multiply (O(a × b)).
  • Halving the problem each step gives O(log n) — binary search, balanced trees.
  • Recursion: count calls × work per call. Two calls each on n−1 → O(2ⁿ).
  • Hash maps are O(1) average, O(n) worst case (collisions).
  • Always mention space too — recursion depth and extra arrays count.

Growth at n = 1,000

log n ≈ 10 · n = 1,000 · n log n ≈ 10,000 · n² = 1,000,000 · 2ⁿ has 302 digits. That is why an O(n²) solution often times out on n = 10⁵ while O(n log n) finishes instantly.

More Interview & Career