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
  1. log₂ n = log₂ 10,000 = 13.2877
  2. O(n log n): 10,000 × 13.2877 = 132,877 operations ÷ 1 × 109 ops/s = 1.329 × 10-4 s
  3. O(n²): 10,000² = 100,000,000 operations ÷ 1 × 109 = 0.1 s
  4. O(2ⁿ): 2^10,000 overflows: astronomically large
  5. 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

Software Engineering formula sheet · All calculators · Practice problems