We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Polynomial vs. Exponential

Broadly speaking, algorithms can be classified into two categories:

  • "Polynomial time"

  • "Exponential time"

Technically O(n!) is "factorial" time, but let's lump them together for simplicity

An algorithm runs in "Polynomial time" if its runtime does not grow faster than n^k, where k is any constant (e.g. n^2, n^3, etc) and n is the size of the input. Polynomial-time algorithms can be useful if they're not too slow.

In comparison, exponential-time algorithms are almost always too slow to be practical. (However, sometimes you're trying to force someone to be slow, like in the case of cryptography and security). Even when n is as low as 20, 2^n is already over a million!

nn^22^n
244
398
41616
52532
63664
749128
864256
981512
101001024
111212048
121444096
131698192
1419616384
1522532768
1625665536
17289131072
18324262144
19361524288
204001048576