This page maps the landscape: the three headline classes P, NP and PSPACE, how they nest inside one another, and the single most famous open question in all of computer science that lives right in the middle of the picture.
P ("polynomial time") is the class of decision problems a
deterministic Turing machine can solve in a number of steps bounded by a
polynomial in the input size
Sorting a list, finding a shortest path, testing whether a number is prime, matching people to jobs — all in P. If a problem is in P, we are basically happy: we have a real algorithm that scales.
NP ("nondeterministic polynomial time") is the class of problems where a proposed solution can be verified in polynomial time — even if finding that solution might be dreadfully hard. The tell-tale shape of an NP problem: a lucky guess (a "certificate") plus a fast checker.
The definition has two equivalent faces: "solvable in polynomial time by a nondeterministic machine that can explore all guesses at once" and "a solution is verifiable in polynomial time with a certificate." The verification view is the one to keep in your head.
NP does not stand for "non-polynomial". It is the single most common misconception about complexity. The "N" is for nondeterministic, and NP is defined by fast checking, not slow solving. In fact every problem in P is also in NP (if you can solve it fast, you can certainly check it fast — just re-solve it and compare). So P is a subset of NP, not the opposite of it.
PSPACE is the class of problems solvable using a polynomial amount of
memory, with no limit at all on time. Space is a far more forgiving resource than
time: a machine can reuse the same cells over and over, so a polynomial-space machine can afford to run
for an exponential number of steps, methodically trying possibilities as long as it never needs more
than
This makes PSPACE roomy. It comfortably contains both P and NP, and it captures problems that feel even harder — like deciding who wins a two-player game (chess, Go, or the abstract game of "geography") where you must reason about every reply to every move. You can search that whole game tree while only ever remembering the single line you are currently exploring.
The classes sit inside one another like Russian dolls. Every containment below is a proven theorem; the one thing nobody knows is whether any of them is actually an equality.
In symbols:
We know
The stakes are enormous. Vast swathes of the problems we wish we could solve efficiently —
scheduling, routing, protein folding, breaking cryptography — are in NP but not known to be in P. If
Here is the intuition for why people bet on