BEGINNER · 10 MIN · FREE LESSON
Time vs space complexity
Explore time vs space complexity through a visual, step-by-step model.
Loading interactive lesson…
BEGINNER · 10 MIN · FREE LESSON
Explore time vs space complexity through a visual, step-by-step model.
Loading interactive lesson…
Compare duplicate detection with and without extra memory.
Extra memory remembers previously seen keys, trading a nested pair scan for expected constant-time set membership checks.
Measured reads + comparisons, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
Write down the names you have seen instead of repeatedly comparing everyone with everyone.
Spend memory to save repeated work. Explore the validated presets and edit the input to check a boundary case.
Predict each decision before advancing. The player checks against the real model and explains why an alternative move fails.
The pair method is quadratic without an early duplicate. Hash-set lookup is expected constant time per key but uses linear extra memory. The chart labels identify actual counters or explicitly modeled recurrence work; display snapshots are not charged to the underlying algorithm.
Switch among JavaScript, Python, Java and C++. The active conceptual stage and live variables connect the code to the trace.
Use this trade-off when remembering previous work avoids repeated scans.
Expected hash-table performance is not a universal worst-case guarantee. Extra memory must be counted separately from time.
Test the invariant and cost model below, then explain the result on a different preset.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.