Big O Calculator
Estimate operations and running time for an algorithm's complexity class at any input size, how time grows when the input doubles, and the largest input that fits a time budget.
Estimated Running Time
10.00 s
Operations
10,00,00,00,000
Largest n within Budget
31,622
If n Doubles
×4 → 40.00 s
Complexity Class
O(n²) quadratic
Big O Growth and Running Time
Pick a complexity class, an input size and the time for one basic operation. The calculator estimates the work and time, what happens when the input doubles, and the biggest input that fits your time budget.
Operation counts
| n | log n | n log n | n² | n³ | 2ⁿ |
|---|---|---|---|---|---|
| 10 | 3.3 | 33 | 100 | 1,000 | 1,024 |
| 100 | 6.6 | 664 | 10,000 | 10⁶ | 1.3 × 10³⁰ |
| 1,000 | 10 | 9,966 | 10⁶ | 10⁹ | 10³⁰¹ |
| 10⁶ | 20 | 2 × 10⁷ | 10¹² | 10¹⁸ | astronomical |
Worked examples
1. O(n²) on 100,000 items at 1 ns (the defaults). 10¹⁰ operations: 10 s; doubling n takes 40 s. Largest n in 1 s: 31,622.
2. O(n log n) sort of a million items. 2 × 10⁷ operations: about 20 ms.
3. O(n²) on a million items. 10¹² operations: 16.7 min; switching to O(n log n) saves almost all of it.
4. O(2ⁿ) brute force with n = 100. 1.27 × 10³⁰ operations: about 4 × 10¹³ years.
Estimates count abstract operations; caching, memory access and constant factors change real times.
Related tools
- Logs: Logarithm Calculator. Memory speed: Cache Hit Calculator.
Frequently Asked Questions
What is Big O notation?
It describes how an algorithm's work grows with input size n, ignoring constant factors. O(n) doubles when n doubles; O(n²) quadruples.
How long will my algorithm take?
Multiply the operation count by the time per basic operation. Simple operations on a modern CPU take roughly 0.3 to 3 ns; 1 ns is a convenient estimate.
What is the largest input that runs in a second?
At 10⁹ simple operations per second: about 10⁹ for O(n), 4 × 10⁷ for O(n log n), 31,000 for O(n²), 1,000 for O(n³), 29 for O(2ⁿ) and 12 for O(n!).
Which is faster, O(n log n) or O(n²)?
O(n log n) for all but tiny inputs. At n = 100,000, n log n is about 1.7 million while n² is 10 billion.
What are common examples of each class?
O(1) array index or hash lookup; O(log n) binary search; O(n) linear scan; O(n log n) merge sort and heap sort; O(n²) bubble or insertion sort; O(2ⁿ) all subsets; O(n!) all permutations.
What happens when the input doubles?
O(n) takes twice as long, O(n²) four times, O(n³) eight times; O(2ⁿ) is squared, so exponential algorithms become impractical quickly.
Which base does log n use?
Base 2 here. In Big O the base does not matter because logs of different bases differ by a constant factor.
Is Big O worst case?
Big O is an upper bound and is usually quoted for the worst case. Quicksort is O(n²) worst case but O(n log n) on average.
Do constants matter in practice?
Yes. Two O(n log n) sorts can differ several-fold in real speed due to memory access and cache behaviour; Big O compares growth, not exact time.
What about space complexity?
The same notation describes memory use. Merge sort needs O(n) extra space; heap sort needs O(1).
Related Calculators
Logarithm Calculator
Calculate log base 10, natural log, and custom base logarithms
Cache Hit Calculator
Calculate cache hit ratio, miss ratio, average memory access time (AMAT), and speedup from cache hits, misses, and access times.
Binary Calculator
Convert between decimal, binary, octal, and hexadecimal number systems. Perform bitwise AND, OR, XOR, NOT, and shift operations.
Boolean Algebra Calculator
Evaluate Boolean logic gates (AND, OR, XOR, NAND, NOR) for up to 3 inputs. View truth table outputs and minterm expressions.
Hash Rate Calculator
Calculate mining hash rate performance, estimated time to find a block, and daily reward based on hash rate, difficulty, and block reward.
Floating Point Calculator
Convert a decimal number to its IEEE 754 floating point representation. View sign, exponent, and mantissa bits for single and double precision.
More in Computer Science · Engineering calculators · All calculators A–Z