A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

The Complexity Class Hierarchy

Graduate Depth 92 in the knowledge graph ☐ I know this ☆ Set as goal
6topics build on this
545prerequisites beneath it
See this on the map →
NP-CompletenessSpace Complexity: PSPACE, L, and NL+4 more→→Alternating Turing Machines and ComplexityInteractive Proofs+2 more
complexity hierarchy PSPACE complexity-classes diagonalization

Core Idea

The major complexity classes form a hierarchy: L ⊆ NL ⊆ P ⊆ NP ⊆ PSPACE ⊆ EXPTIME. The time hierarchy theorem, proved by diagonalization, guarantees that strictly more time yields strictly more computational power: DTIME(n) ⊊ DTIME(n²). Similarly, the space hierarchy theorem shows DSPACE(log n) ⊊ DSPACE(n). It is proven that P ⊊ EXPTIME, so the hierarchy is strict overall, but the intermediate separations — P vs. NP, NP vs. PSPACE — remain open. The polynomial hierarchy extends NP with alternating quantifiers, analogous to the arithmetical hierarchy.

How It's Best Learned

Study the hierarchy theorem proofs as applications of diagonalization — the same technique used for the halting problem. Then map out which containments are proven strict and which remain open, building an accurate picture of current knowledge.

Common Misconceptions

Explainer

You already understand P and NP as the heart of the complexity landscape — P is what deterministic polynomial time can decide, NP is what nondeterminism adds. But these two classes sit inside a much richer landscape. Think of computational resources — time and space — as two different currencies. Using more of one can sometimes substitute for the other, and the complexity hierarchy maps out exactly which tradeoffs are possible and which boundaries are real.

PSPACE is the class of problems solvable with polynomial *space*, regardless of how long computation takes. Because space can be reused across time steps, PSPACE is potentially much larger than NP: a problem might require exponential time but only polynomial space to solve, since you can reuse the same memory cells for many different subcomputations. The canonical PSPACE-complete problem is TQBF (totally quantified Boolean formulas), which asks whether a formula with alternating universal and existential quantifiers is true — the same structure as adversarial games. This connects PSPACE to problems like determining the winner of a board game under optimal play.

Above PSPACE sits EXPTIME — problems solvable in exponential time — and we *do* know that P ⊊ EXPTIME is a strict containment. The proof uses diagonalization, the same technique you saw with Cantor and the halting problem. The time hierarchy theorem shows that given strictly more time, you can solve strictly more problems: DTIME(nk) ⊊ DTIME(nk+1) for all k. The argument constructs a language by diagonalizing against all machines running in time T(n), building a problem that deliberately answers differently from every such machine. Similarly, the space hierarchy theorem shows DSPACE(log n) ⊊ DSPACE(n).

The polynomial hierarchy (PH) extends NP with alternating quantifiers: Σ₁ = NP, Π₁ = co-NP, Σ₂ = NPNP (NP with an NP oracle), and so on. This mirrors the arithmetical hierarchy you may know from logic. A key structural fact: if P = NP, then PH collapses to P — every level becomes equivalent. This is a reason (not a proof!) that P ≠ NP is expected: the polynomial hierarchy seems to be genuinely infinite. The current picture is: we know P ⊊ EXPTIME strictly, we know P ⊆ NP ⊆ PSPACE ⊆ EXPTIME, but the intermediate separations — P vs. NP, NP vs. PSPACE — remain among the deepest open problems in mathematics.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Introduction to Propositional Logic → Introduction to Predicate Logic (First-Order Logic) → First-Order Logic Syntax → ZFC Axioms Overview → Axiom Schema of Separation → Axiom Schema of Replacement → Von Neumann Ordinals → Hereditarily Finite Sets → Recursive Definitions on Finite Sets → Well-Founded Relations and Transfinite Recursion → The Axiom of Choice and Equivalent Formulations → Axiom of Choice → Well-Ordering Theorem → Infinite Cardinal Numbers → Cantor's Theorem → Uncountability and the Diagonal Argument → The Cantor Set: An Uncountable Nowhere Dense Example → Uncountable Sets and Cantor Diagonalization → The Halting Problem → Computability Reductions → Polynomial-Time Reductions → Lower Bounds Techniques in Computational Complexity → NP-Completeness → The Complexity Class Hierarchy

Longest path: 93 steps · 545 total prerequisite topics

Prerequisites (6)

Leads To (4)