Big-O Complexity Comparator
Compare algorithm growth rates with deterministic, client-side curves and operation counts.
Examples
n log n at n=1000
calculateOperations("linearithmic", 1000)9965.78 (≈9966, i.e. 1000 × log₂ 1000)The linearithmic branch multiplies n by Math.log2(n); at 1000 that is 9965.78, within 1 of 9966.
Exponential saturation and resolution
calculateOperations("exponential", 10000)
generateCurvePoints("linear", 100, 33).length9007199254740991 (MAX_OPERATIONS)
332^10000 is capped at MAX_OPERATIONS instead of Infinity, and the curve sampler returns exactly the requested point count.
About this tool
Big-O Complexity Comparator evaluates operation counts with calculateOperations (also aliased as evaluateComplexity, calculateComplexity, and getOperationCount) across eight classes: O(1), O(log n), O(n), O(n log n), O(n²), O(n³), O(2ⁿ), and O(n!). Logarithmic terms use base-2 Math.log2, so O(n log n) at n=1000 is exactly 1000 × log₂(1000) ≈ 9965.78. Every growing class is clamped into [0, MAX_OPERATIONS] (Number.MAX_SAFE_INTEGER) by the internal cap helper, so explosive inputs such as 2^10000 or 1000! saturate at MAX_OPERATIONS instead of overflowing to Infinity.
Curves are sampled with generateCurvePoints(id, maxN = 100, pointCount = 80, logScale = false), which spaces pointCount points linearly from n=1 to maxN, normalizes x to [0, 1] and y against the series maximum (or a log10 span when logScale is on), and returns { n, value, x, y } tuples. generateCurvePath renders the same points as a deterministic SVG path string (M followed by L commands with 4-decimal coordinates), so identical arguments always produce byte-identical output. createComparisonTable builds one row per complexity with values at [10, 100, 1000, 1_000_000] by default, and getComplexityDefinition resolves an id to its label, expression, and color.
Display formatting goes through formatOperations, which renders MAX_OPERATIONS as “≥ 9.0 quadrillion”, integers with en-US thousands separators, and fractional values with up to two decimals. Non-positive or non-finite input sizes are coerced to 0 (constant still returns 1, logarithmic returns 0 at n=0), and the point count is floored to at least 2, so degenerate arguments degrade gracefully instead of throwing.
How to use this tool
Compare operation counts
Call calculateOperations with a complexity id and n, or read createComparisonTable rows at 10, 100, 1000, and 1M to see how linearithmic (≈9966 at n=1000) diverges from quadratic and exponential.
Plot a curve
Choose maxN and a pointCount resolution, then call generateCurvePoints or generateCurvePath. The returned array length always equals the requested resolution (minimum 2), and the path starts with M 0.0000.
Toggle log scale
Pass logScale true to normalize y over the log10 span, which keeps O(1) through O(n!) visible on one chart. Monotonic inputs stay monotonic in y.
Format large counts
Pass raw counts through formatOperations for display: capped values read “≥ 9.0 quadrillion” and ordinary integers gain thousands separators.
Use cases
Choosing between algorithms
Compare n log n sorting against quadratic nesting at realistic input sizes before committing to an implementation.
Charting growth for docs and teaching
Render deterministic SVG paths or normalized point arrays to visualize why exponential and factorial curves leave the chart first.
Sanity-checking capacity plans
Read the comparison table at 1M inputs to show stakeholders when cubic or exponential work becomes physically impossible.
Common mistakes
Mistake:Expecting exact 2ⁿ or n! values at large n.
Fix:Both branches saturate at MAX_OPERATIONS by design. Treat the “≥ 9.0 quadrillion” rendering as “too large to compute”, not as an exact count.
Mistake:Reading log₂ results as natural-log values.
Fix:The logarithmic and linearithmic branches use Math.log2. Convert explicitly (ln n = log₂ n × ln 2) when comparing against textbook natural-log formulas.
Mistake:Assuming pointCount is a maximum rather than exact.
Fix:generateCurvePoints returns exactly max(2, floor(pointCount)) points, and generateCurvePath emits one M/L command per point. Size downstream buffers for the exact count.
Frequently asked questions
What does this tool do?
It evaluates operation counts with calculateOperations across O(1), O(log n), O(n), O(n log n), O(n²), O(n³), O(2ⁿ), and O(n!), samples deterministic SVG-ready curves with generateCurvePoints/generateCurvePath, builds comparison-table rows with createComparisonTable, and formats counts for display with formatOperations.
What is n log n at n=1000, and what happens to huge exponentials?
O(n log n) at n=1000 is 1000 × log₂(1000) ≈ 9965.78 (within 1 of 9966). Explosive inputs saturate instead of overflowing: 2^10000 and 1000! both return MAX_OPERATIONS (Number.MAX_SAFE_INTEGER), rendered as “≥ 9.0 quadrillion”.
Is my input uploaded or stored?
No. All math is pure client-side arithmetic — input sizes and counts never leave your browser.
How do log scale and resolution behave?
Pass logScale true to normalize y over the log10 span so all eight classes stay visible; monotonic inputs stay monotonic in y. The sampler returns exactly max(2, floor(pointCount)) points, and the SVG path emits one M/L command per point starting with M 0.0000.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML