Big O Calculator
Enter an input size to see how different time complexities scale. Compare operation counts and estimated runtimes across all major Big O classes.
Runtime estimates are approximate — click for methodology & sources
Multipliers are relative to C++ (~1 ns/op baseline): Rust ~1.1x, Go ~2x, Swift ~2.5x, Java ~3x, Kotlin ~3.2x, C# ~3.5x, JS/TS ~5x, PHP ~15x, Ruby ~30x, Python ~40x.
Sources:
- Computer Language Benchmarks Game (benchmarksgame-team.pages.debian.net) — canonical cross-language compute benchmarks
- TechEmpower Framework Benchmarks (techempower.com/benchmarks) — real-world web framework performance
- “Energy Efficiency across Programming Languages” (Pereira et al., SLE 2017) — academic study comparing 27 languages
These are conservative medians from compute-bound workloads (sorting, matrix ops, fibonacci). Real performance varies significantly by workload type, compiler flags, JIT warmup, GC tuning, and hardware.
How to Use This Tool
- Step 1Enter Input Size
Type a number or click a preset (10, 100, 1K, 10K, 100K, 1M) to set the input size n.
- Step 2Compare Complexities
See 8 complexity classes side by side — from O(1) constant to O(n!) factorial — with exact operation counts.
- Step 3Read Estimated Runtimes
Each card shows estimated wall-clock time assuming ~1 ns per operation. Compare across JavaScript, C++, and Python.
- Step 4Use for Interview Prep
Practice identifying which complexity class your algorithm falls into. Compare to see why O(n²) breaks at scale.
- •For interview prep, try n = 10,000 — most O(n²) algorithms start to feel slow here.
- •Exponential O(2ⁿ) becomes infeasible beyond n ≈ 25. Factorial O(n!) beyond n ≈ 12.
- •Real-world algorithms are faster due to caching, SIMD, and compiler optimizations — these estimates are worst-case upper bounds.
What is Big O Notation?
Big O notation describes the upper bound of an algorithm's time or space complexity as the input size grows. It helps developers compare algorithms and predict performance at scale.
Common complexity classes from fastest to slowest: O(1) constant, O(log n) logarithmic, O(n) linear, O(n log n) linearithmic, O(n²) quadratic, O(2ⁿ) exponential, O(n!) factorial.
Understanding Big O is essential for technical interviews at companies like Google, Meta, Amazon, and Microsoft. This calculator helps you visualize how input size affects algorithm performance.