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

Space Complexity: PSPACE, L, and NL

Graduate Depth 83 in the knowledge graph ☐ I know this ☆ Set as goal
39topics build on this
484prerequisites beneath it
See this on the map →
Time Complexity and the Class PAlgorithm Analysis and Big-O Notation+3 more→→Circuit ComplexityComplexity Classes and the Complexity Hierarchy+4 more
complexity space-complexity PSPACE logarithmic-space

Core Idea

Space complexity measures the number of tape cells a TM uses on an input of length n. PSPACE is the class of problems solvable in polynomial space; it contains both P and NP and is known to contain problems harder than any fixed polynomial. L and NL are the classes solvable in O(log n) space deterministically and nondeterministically; NL contains graph reachability (STCON). Savitch's theorem shows that nondeterministic space S(n) ≥ log n can be simulated deterministically in S(n)² space, so NPSPACE = PSPACE — a striking contrast to the unresolved P vs. NP question.

How It's Best Learned

Contrast space with time: space can be reused across computation steps but time cannot. Work through Savitch's theorem to see why nondeterministic and deterministic space are polynomially related, while the analogous time question (NP ⊆ P?) remains open. Study QBF satisfiability as the canonical PSPACE-complete problem.

Common Misconceptions

Explainer

When we measure complexity by time, we count computation steps. Space complexity counts something different: the number of distinct tape cells written during the computation. The crucial difference is that space is *reusable* — after a machine finishes using part of the tape for an intermediate result, it can overwrite those cells. Time does not share this property; each step is consumed and cannot be revisited. This asymmetry is what makes space complexity behave so differently from time complexity.

PSPACE is the class of problems solvable using at most a polynomial number of tape cells. It contains both P and NP — any nondeterministic polynomial-time computation uses at most polynomial space — but PSPACE may contain harder problems still. The canonical PSPACE-complete problem is QBF (Quantified Boolean Formula satisfiability): determining the truth of a fully quantified Boolean formula such as ∀x∃y(x ∨ y). Solving QBF requires systematically exploring all assignments under alternating quantifiers, which is believed to require super-polynomial time despite using only polynomial space.

Savitch's theorem establishes a striking result: NPSPACE = PSPACE. Any nondeterministic machine using S(n) ≥ log n space can be simulated by a deterministic machine using O(S(n)²) space. The simulation works by a recursive divide-and-conquer: "can configuration A reach configuration B in k steps?" is answered by guessing a midpoint configuration M and recursively asking "can A reach M in k/2 steps?" and "can M reach B in k/2 steps?" Each recursive call reuses the same space, keeping total usage polynomial. Crucially, this technique cannot be applied to time because each recursive sub-call requires its own time steps — they cannot be reused or shared.

L and NL are the log-space classes, and they sit at the other end of the spectrum from PSPACE. L allows only O(log n) bits on the working tape — enough to store O(1) pointers into the input, but not enough to copy it. This is surprisingly powerful: O(log n) bits can represent any index from 0 to n-1, so a log-space machine can navigate the input freely using a handful of counters. NL adds nondeterminism and contains graph reachability (STCON): a nondeterministic log-space machine solves reachability by guessing one node at a time along the path, keeping only the current node in memory.

These classes fit into a containment hierarchy: L ⊆ NL ⊆ P ⊆ NP ⊆ PSPACE ⊆ EXP. At least one of these containments is strict (PSPACE ⊊ EXP), but most boundaries — including P vs. NP and NL vs. P — remain unproven. Space complexity adds depth to the complexity landscape, revealing that the central open questions about hardness are just the most visible part of a much larger web of unresolved separations.

Practice Questions 3 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 → Dividing Integers → Unit Rates → Proportions → Percent Concept → Converting Between Fractions, Decimals, and Percents → Operations with Rational Numbers → Two-Step Equations → Solving Multi-Step Equations → Equations with Variables on Both Sides → Literal Equations → Slope-Intercept Form → Point-Slope Form → Writing Linear Equations → Parallel and Perpendicular Line Slopes → Graphing Linear Equations → Piecewise Functions → Step Functions → Composition of Functions → Inverse Functions → Radical Functions and Graphs → Rational Exponents → Exponential Functions and Graphs → Logarithms Introduction → Big-O Notation and Asymptotic Analysis → Breadth-First Search (BFS) → Shortest Paths in Unweighted Graphs → Dijkstra's Shortest Path Algorithm → Algorithm Analysis and Big-O Notation → Turing Machines → Time Complexity and the Class P → Nondeterministic Turing Machines → Space Complexity: PSPACE, L, and NL

Longest path: 84 steps · 484 total prerequisite topics

Prerequisites (5)

Leads To (6)