This visual guide is designed for students who understand some code but need a stronger mental picture of how the data structure or algorithm behaves. Use the diagram first, then connect it to code.
Growth changes when input size doubles
| Runtime | n = 10 | n = 100 | Pattern |
|---|---|---|---|
| O(1) | 1 step | 1 step | fixed access |
| O(log n) | about 4 | about 7 | halving |
| O(n) | 10 | 100 | one pass |
| O(n^2) | 100 | 10,000 | all pairs |
Mental model
Big-O is a growth story. Students should ask what work increases as the input grows, then ignore tiny constants and focus on the dominant pattern.
How it shows up in code
A loop over every item is linear. A nested loop over every pair is quadratic. Binary search is logarithmic because each comparison removes about half the remaining candidates.
What to trace
Practice prompt
Take three school-assignment methods and label the dominant operation: one array scan, one pair comparison, and one binary search.
When students need support
Code Scholars helps students turn the visual model into implementation, tests, edge-case reasoning, and runtime analysis. This is especially useful when students can follow an explanation but struggle to write the code independently.
