Computational Complexity Basics
Before we can ask what a quantum computer buys us, we need the vocabulary of classical complexity theory: the precise way computer scientists measure "how hard" a problem is and compare problems to one another. This lesson reviews the asymptotic worst-case framework, the central classes and , and the notion of a reduction that organizes problems by difficulty.
Decision problems and resource scaling
Complexity theory is cleanest for decision problems — questions with a yes/no answer, identified with a language , the set of inputs whose answer is "yes." We measure the resources a machine uses (time = number of steps, space = memory cells) as a function of the input length , and we care about worst-case asymptotics: how the resource grows as , up to constant factors and lower-order terms. The relevant dividing line is polynomial versus superpolynomial. A running time for some fixed constant is "efficient"; a time like or is not.
This focus on polynomials is deliberate. Polynomials are closed under addition, multiplication, and composition, so "efficient" is robust: chaining a polynomial number of polynomial-time subroutines is still polynomial. It also makes the theory machine-independent — the strong Church–Turing thesis asserts that any two reasonable classical models simulate each other with only polynomial overhead, so "polynomial time" means the same thing on a Turing machine, a RAM, or a C program.
The class P
is the canonical formalization of tractable. Sorting, shortest paths, linear programming, and primality testing all live in . A problem in has an algorithm that, on every input, halts with the correct answer after a polynomial number of steps.
The class NP
is the class of decision problems whose yes-instances admit a short, efficiently checkable certificate. Formally, if there is a polynomial-time verifier and a polynomial such that
The string is a witness or proof. For Boolean satisfiability (), the witness is a satisfying assignment, and checking it is trivial. For graph 3-colouring, the witness is the colouring. The defining asymmetry: finding may be astronomically hard, but verifying a claimed is easy.
Reductions and completeness
To compare two problems we use a reduction. A polynomial-time many-one reduction from to , written , is a polynomial-time computable map such that
If such an exists, then is "at least as hard" as : any efficient algorithm for yields one for by first running . Reductions impose a partial order of difficulty on problems.
A problem is -hard if every reduces to it, and -complete if it is both -hard and itself in . The Cook–Levin theorem established the first -complete problem, ; thousands more (3-colouring, Hamiltonian cycle, subset-sum, …) followed by reduction from it. -complete problems are the hardest problems in : an efficient algorithm for any one of them would collapse .
Beyond P and NP
Two more classes recur throughout this module. (bounded-error probabilistic polynomial time) allows the machine to flip fair coins and to err with probability at most on every input; it is the realistic classical notion of "efficient" once randomness is permitted. is everything decidable with a polynomial amount of memory, regardless of time. The standard, widely believed inclusions are
with as well. Almost all of these inclusions are not known to be strict: separating them is exactly the hard open territory of the field.
What to carry forward
Three ideas anchor the rest of this module. First, polynomial time is the threshold of efficiency, and it is robust across machine models. Second, is about verification, not solution — short checkable proofs. Third, reductions and completeness let us name the hardest problems in a class without solving them. The quantum classes and we meet next are the quantum analogues of and , built on exactly this scaffolding.
Sign in on the full site to ask questions and join the discussion.