5 exercises on weighing time versus space, saying Big-O out loud, and justifying a design choice.
Key patterns
The trade-off here is time versus space... — name the axis.
This runs in oh n squared time, because... — say Big-O and justify.
I could optimise by..., but that costs... — justify your choice.
On average... but in the worst case... — separate the cases.
0 / 5 completed
1 / 5
You chose a hash set to deduplicate a list. The interviewer asks why. Which answer explains the trade-off most clearly?
Name the trade-off, then quantify both sides.
The signature phrase is The trade-off here is X versus Y. A strong answer states the axis (time vs space), gives the Big-O for each, and names the alternative you would pick under different constraints. Patterns:
The trade-off here is time versus space...
We are trading memory for speed.
If memory were tight, I would instead...
Options A, B and D give a preference with no reasoning. Interviewers want to hear that you understand why one cost is acceptable here and when you would flip the decision.
2 / 5
You need to say a Big-O complexity out loud for a nested loop over n items. Which is phrased most naturally?
Read complexity the way engineers actually say it.
O(n²) is spoken as "oh n squared" or "order n squared"; O(n log n) is "oh n log n"; O(1) is "constant time" or "oh one". Always justify the count: here, an inner loop of n inside an outer loop of n gives n × n. Phrases:
This runs in oh n squared time.
That is constant time, oh one.
Asymptotically this is linear.
Option B and C misname it; D shows you cannot reason about the count. Saying the complexity and the reason is what earns the mark.
3 / 5
An interviewer pushes back: Could you make it faster? You can, but only by using more memory. Which response justifies your choice best?
Acknowledge the faster path, then justify staying put.
The mature answer is not always "make it faster" — it is showing you know how and can weigh the cost. The good option names the optimisation (lookup table), the gain (O(n log n) → O(n)), the cost (memory, cache pressure), and a decision rule (profile first). Phrases:
I could optimise by..., but that costs...
Premature optimisation would add complexity for little gain here.
I would let profiling guide that.
Option A wrongly claims it is optimal; C hand-waves; D dismisses the question. Justifying a choice means making the cost-benefit explicit.
4 / 5
You are comparing two designs aloud. Which sentence contrasts them most professionally?
Use contrast connectors and a deciding factor.
Professional comparison hinges on connectives like whereas, on the other hand, and by contrast, plus a clear deciding variable (here, read-heavy vs write-heavy workload). Patterns:
Whereas X is simpler, Y scales better, so...
On the other hand, the cost of Y is...
It depends on whether reads or writes dominate.
Options A and B refuse to differentiate; D shows indecision. Tying the recommendation to a workload characteristic demonstrates engineering judgement, not just memorised complexities.
5 / 5
The interviewer asks about the worst case versus the average case of your quicksort. Which explanation is strongest?
Separate average and worst case, and give the trigger plus a fix.
Distinguishing cases is core interview vocabulary: on average vs in the worst case vs amortised. The strong answer names quicksort's average O(n log n), the worst-case O(n²), the trigger (sorted input, bad pivot), and a mitigation (randomised / median-of-three pivot). Phrases:
On average... but in the worst case...
This is amortised constant time.
I would mitigate that by...
Option A is factually wrong (quicksort's worst case is O(n²)); C is imprecise; D dodges the question. Precision about cases is a clear seniority signal.