Big-O Complexity Explainer

Select an n value to see how many operations each complexity class requires, plus a Chart.js growth curve comparison for all major Big-O notations.

Big-O Complexity Reference

Big-O notation describes how an algorithm's resource usage scales with input size n. Adjust n below to see operation counts for every complexity class, and read the growth chart to understand how they diverge.

(1 – 20; values above 20 are capped for factorial)
Notation Name Description Example algorithms Ops at n=10

Growth Curve Comparison

X axis: input size n (1–20). Y axis: approximate operation count (log scale).

O(1)
Constant

Execution time is fixed regardless of n. Ideal. Think array index lookup or hash table access.

O(log n)
Logarithmic

Input is halved each step. Binary search on a sorted array is the textbook example.

O(n)
Linear

Each additional element adds a fixed amount of work. A single pass through an array or linked list.

O(n log n)
Linearithmic

The optimal bound for comparison-based sorting. Merge sort, heap sort, and quicksort (average).

O(n²)
Quadratic

Nested loops over the input. Bubble sort, selection sort, and naive matrix multiplication.

O(2^n)
Exponential

Doubles with every additional element. Recursive subset enumeration, naive Fibonacci, traveling salesman (brute force).

O(n!)
Factorial

Permutation generation and brute-force TSP. Infeasible past n = 20 on any modern hardware.

O(n³)
Cubic

Triple nested loops. Naive matrix multiplication and Floyd–Warshall shortest path algorithm.

Summary

Select an n value to see how many operations each complexity class requires, plus a Chart.js growth curve comparison for all major Big-O notations.

How it works

  1. For a user-supplied n, the tool evaluates each complexity formula (1, log2(n), n, n*log2(n), n^2, 2^n, n!) and renders the counts in a reference table. Chart.js plots growth curves across a range of n values so you can see visually how each class diverges.

Use cases

  • Compare algorithm candidates during a code review or interview prep.
  • Quickly look up what O(n log n) means relative to O(n²) for a given data size.
  • Teach Big-O to junior developers with a visual, interactive reference.
  • Estimate whether a brute-force approach is feasible before optimizing.
  • Use as a cheat-sheet during competitive programming or technical interviews.

Frequently Asked Questions

Last updated: 2026-06-11 · Reviewed by Nham Vu