Algorithm complexity (Big-O) calculator
How long algorithms of different complexity take as the input grows. Enter your values and see the formula, your numbers plugged in and every step of the working. Free, no sign-up, SI and imperial units.
Formula
time = (number of operations) / (operations per second)
Inputs
- Input size (n)
- Operations per second (ops/s)
Worked example: 10,000 items on a machine doing 10⁹ simple operations per second
- Input size n = 10000
- Operations per second ops/s = 1000000000
- log₂ n = log₂ 10,000 = 13.2877
- O(n log n): 10,000 × 13.2877 = 132,877 operations ÷ 1 × 109 ops/s = 1.329 × 10-4 s
- O(n²): 10,000² = 100,000,000 operations ÷ 1 × 109 = 0.1 s
- O(2ⁿ): 2^10,000 overflows: astronomically large
- Big-O ignores constant factors. Real code can be several times faster or slower than these estimates.
Answer: O(n log n) runtime O(n log n) = 132.877 µs; O(1) runtime O(1) = 0.001 µs; O(log n) runtime O(log n) = 0.0132877 µs; O(n) runtime O(n) = 10 µs; O(n²) runtime O(n²) = 100 ms; O(n³) runtime O(n³) = 0.277778 h; O(2ⁿ) runtime: longer than the age of the universe
More software engineering calculators
- Amdahl's law (parallel speed-up): Maximum speed-up from running part of a program on more processors.
- Number base converter: Convert between binary, octal, decimal and hexadecimal, with the working.
- IP subnet calculator: Network, broadcast, mask and host range of an IPv4 address in CIDR form.
- Password strength (entropy): Entropy of a random password and how long brute force would take.
Software Engineering formula sheet · All calculators · Practice problems