MEPLAT.

Big-O Sprint

Rules

Read the short piece of pseudo-code and pick how its running time grows with n.

Press 1 to 4 or click. Pick the tightest class on offer.

A wrong pick shows the answer with a one-line reason and moves on. Tab skips.

Difficulty moves from single loops to nested, halving and dependent loops, then recursion and amortised cases.

Examples

1. for (i = 0; i < n; i++) for (j = 0; j < n; j++) count += 1
O(n^2)

2. i = 1; while (i < n) i = i * 2
O(log n)

3. f(n): if (n <= 1) return; f(n / 2); f(n / 2); then a loop of n steps
O(n log n)

Time (min/sec):