AlgoViz

O(2ⁿ) exponential time

easy 15 min

O(2ⁿ) means the work doubles every time one more item is added.

Where it shows up

The same pattern appears across everyday software.

  • Packing and budgeting (knapsack)

    Choosing which items to ship, which projects to fund or which ads to run under a budget is a knapsack problem. Trying every subset is O(2ⁿ), so real systems use dynamic programming over the budget, branch and bound, or approximations.

  • Puzzle and constraint solvers

    Sudoku, N-Queens, crosswords and timetabling solvers are backtracking searches over a tree of choices. Pruning a bad partial answer early removes whole subtrees, which is what makes them finish in practice.

  • Cryptography by design

    Encryption keys are chosen so that brute force is exponential. A 128-bit key has 2^128 possibilities; even a trillion guesses per second for the age of the universe would cover a tiny fraction of them.

  • Chip and software verification

    Checking a circuit or a configuration for every combination of n boolean inputs means 2ⁿ cases. SAT solvers handle millions of variables by pruning and learning from conflicts instead of enumerating.

  • Route planning

    Delivery routing is a traveling salesman problem. Brute force over all orders is factorial; the Held-Karp DP over subsets is O(n² · 2ⁿ), still exponential, so large fleets use heuristics.

  • Testing configuration combinations

    A product with 30 on/off feature flags has over a billion combinations. Test teams use pairwise testing, which covers every pair of settings in a small number of runs.