Time Complexity Visualizer
Compare Big O growth: O(1), O(log n), O(n), O(n log n), and O(n²) on interactive charts with plain-language explanations.
Complexity & input size
Choose growth classes and set n. The graph spans 1…1000; the pink line marks your current n. Code and operation counts update from the same value (formulas only for large n).
Growth curves
Visualization
- O(n)y = n
- O(n²)y = n²
Code example
// O(n) — one pass over n elements
for (let i = 0; i < n; i++) {
console.log(i);
}Execution (formula)
Counts use the standard growth formulas — no heavy loops in the browser.
- O(n)Operations: 10
- O(n²)Operations: 100
Step preview (n = 10)
Showing trace for O(n) — switch tabs above.
- i = 0
- i = 1
- i = 2
- i = 3
- i = 4
- i = 5
- i = 6
- i = 7
- i = 8
- i = 9
- total iterations: 10
What does this mean?
At your current n
For n = 10, O(n): ~10 operations; O(n²): ~100 operations. O(n²) does about 10.0× as much work as O(n) at this n — that gap widens as n grows.
O(n)
Linear time: work scales proportionally with n. A single pass over an array is usually O(n).
O(n²)
Quadratic growth: often from nested loops over the same input. Becomes expensive quickly as n grows — algorithms may need optimization or better structure.
Time Complexity Visualizer guide
Developer Tool
Big O notation describes how the work an algorithm needs grows when the input size n grows—not the exact millisecond runtime on your laptop, but the shape of that growth. Interviewers use it to compare approaches; engineers use it to spot nested loops that will hurt at scale. Numbers on a whiteboard are easy to misread, so plotting abstract “operations” against n turns familiar symbols into lines you can actually see diverge. This tool keeps the math honest: logarithmic factors use base 2 to match how computer scientists discuss halving steps, quadratics follow n squared, and you can overlay several complexities to watch faster algorithms hug the bottom while aggressive growth shoots upward. Everything runs locally in the browser, which makes it a safe companion for classrooms, study groups, and quick intuition checks before you profile real code.
Why visualize time complexity?
Humans are better at comparing curves than memorizing tables. When you overlay O(n) and O(n²), the quadratic line bends upward in a way that a bullet list cannot convey. Logarithmic curves look almost flat next to polynomials until n becomes large enough—exactly the intuition binary search teachers want students to feel. A chart also reinforces that Big O hides constants: two O(n) algorithms can differ in real speed, but both stay in the same growth family as n increases.
Educational tools should stay transparent. Here, the y-axis is an abstract operation count derived from the standard forms taught in algorithms courses, not a benchmark of your hardware. Toggle a logarithmic axis when you compare families with very different slopes so slow-growing lines remain visible next to steep ones.
How to use the visualizer
Pick one or more complexity classes with the checkboxes. The chart samples values of n from 1 up to the maximum you choose on the slider, plotting the corresponding growth functions. Equations appear inline above the graph so you always know which line corresponds to which formula—y = 1 for constant time, y = log₂(n) for logarithmic, and so on.
Use “Select all” to see every option at once, or the “Sorts” preset to contrast O(n log n) with O(n²)—a classic lesson from introductory algorithms. When multiple curves are active, enable the logarithmic Y-axis to keep exponential separation readable; switch back to linear for a single curve if you want distances on the axis to match raw growth more literally.
From graphs to real engineering
Big O is a model, not a substitute for measurement. Caching, branch prediction, and memory hierarchy dominate small n; profiling still matters after you choose the right asymptotic class. Use this visualizer to communicate with teammates—“our nested filter is quadratic in the list length”—and then validate with timers on realistic data sizes.
Pair the chart with TinkerTools’ other developer utilities when you are debugging payloads or sketching API calls. When you teach, encourage learners to predict which line will be highest at n = 1000 before revealing the plot; that prediction loop builds durable intuition.
Related tools
Explore these related tools to complete your workflow faster.