Big-O: describe growth, not microseconds

Beginner Asymptotics & empirical timing
Created by Pavel · 29.04.2026 at 19:08 UTC

Big-O notation answers: “If I double the training set / feature dimension / graph size, what happens to runtime in the limit?” It deliberately hides constant factors and hardware details—those still matter for a 10× speedup on a fixed workload, but they do not tell you whether an algorithm survives a move from 10⁴ to 10⁸ rows.

In data science you routinely contrast O(n) scans, O(n log n) sorts and divide-and-conquer routines, O(n²) naive all-pairs or nested-loop feature interactions, and worse. Best, average, and worst cases differ: quicksort’s average behaviour is not its worst case; adversarial inputs exist for many textbook algorithms.

Asymptotics pair with empirical profiling: a “fast” O(n²) on small n can beat a heavy O(n log n) with giant constants until n crosses over. Use Big-O to reason about scaling; use timers and profilers to choose implementations at the sizes you actually run.

Complexity cheat sheet (educational): [1].


Sources

University approvals: 0
Tasks
Question 1

Which growth class dominates f(n) = 7 * n**3 + 1000 * n**2 + n for very large n (standard Big-O view)?

Hint

Pick the highest-degree polynomial term.

Question 2

Merge sort’s typical worst-case time complexity for n comparable elements is:

Hint

Divide and merge both halves recursively.

Question 3

You benchmark two dataframe row operations at n=500 and pick the slower algorithm because its constant factor is tiny. At n=200_000 the ranking flips. What lesson matches Big-O thinking?

Hint

Small-n winners need not be large-n winners.

Card Info
  • Topic: Asymptotics & empirical timing
  • Difficulty: Beginner
  • Completed: 0 users
Creator
Pavel
Pavel