Big-O Complexity Explainer
Select an n value to see how many operations each complexity class requires, plus a Chart.js growth curve comparison for all major Big-O notations.
Big-O Complexity Reference
Big-O notation describes how an algorithm's resource usage scales with input size n. Adjust n below to see operation counts for every complexity class, and read the growth chart to understand how they diverge.
| Notation | Name | Description | Example algorithms | Ops at n=10 |
|---|
Growth Curve Comparison
X axis: input size n (1–20). Y axis: approximate operation count (log scale).
Execution time is fixed regardless of n. Ideal. Think array index lookup or hash table access.
Input is halved each step. Binary search on a sorted array is the textbook example.
Each additional element adds a fixed amount of work. A single pass through an array or linked list.
The optimal bound for comparison-based sorting. Merge sort, heap sort, and quicksort (average).
Nested loops over the input. Bubble sort, selection sort, and naive matrix multiplication.
Doubles with every additional element. Recursive subset enumeration, naive Fibonacci, traveling salesman (brute force).
Permutation generation and brute-force TSP. Infeasible past n = 20 on any modern hardware.
Triple nested loops. Naive matrix multiplication and Floyd–Warshall shortest path algorithm.
Summary
Select an n value to see how many operations each complexity class requires, plus a Chart.js growth curve comparison for all major Big-O notations.
How it works
- For a user-supplied n, the tool evaluates each complexity formula (1, log2(n), n, n*log2(n), n^2, 2^n, n!) and renders the counts in a reference table. Chart.js plots growth curves across a range of n values so you can see visually how each class diverges.
Use cases
- Compare algorithm candidates during a code review or interview prep.
- Quickly look up what O(n log n) means relative to O(n²) for a given data size.
- Teach Big-O to junior developers with a visual, interactive reference.
- Estimate whether a brute-force approach is feasible before optimizing.
- Use as a cheat-sheet during competitive programming or technical interviews.