Skip to content
Lydia Hallie theavocoder
Big O contents
Big O Notation / O(2ⁿ)

Exponential

Exponential time means the work doubles every time the input grows by one. A naive recursive Fibonacci function is the classic example.

function fib(n) {
  if (n <= 1) return n;
  return fib(n - 1) + fib(n - 2);
}

Each call branches into two more calls, so the number of calls explodes. Small inputs feel fine. Larger inputs become impractical very quickly.

Exponential time is not always a dead end. Memoization, dynamic programming, and a better recurrence can turn many exponential problems into polynomial ones. The first step is recognizing the shape.

References and further reading