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.

Built by Sabki SolutionsRules: O(1) to O(n!)Last updated
110,00,00,00,00,000
ns
0.001ns10,00,000.000ns
s
0.001s10,00,000.000s

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

nlog nn log nn²n³2ⁿ
103.3331001,0001,024
1006.666410,00010⁶1.3 × 10³⁰
1,000109,96610⁶10⁹10³⁰¹
10⁶202 × 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

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

More in Computer Science · Engineering calculators · All calculators A–Z