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 94 in the knowledge graph ☐ I know this ☆ Set as goal
10topics build on this
495prerequisites beneath it
See this on the map →
Time Complexity Classes: P and EXPTIMEAsymptotic Notation: Big-O, Big-Omega, Big-Theta+2 more→→EXPTIME and EXPSPACE Complexity ClassesPSPACE Complexity Class+2 more
PSPACE L NL space-complexity Savitch

Core Idea

Space complexity classes measure memory usage rather than time. PSPACE contains problems solvable in polynomial space (e.g., quantified Boolean formula satisfiability, TQBF), and is known to contain NP and P. The class L consists of problems solvable in logarithmic space on a deterministic TM; NL uses nondeterministic log space. Savitch's theorem shows NPSPACE = PSPACE, meaning nondeterminism buys much less in space than it might in time. Space and time complexity interact deeply: PSPACE ⊆ EXPTIME, and P ⊆ NP ⊆ PSPACE, but most containments are strict.

How It's Best Learned

Work through the TQBF PSPACE-completeness proof as the space analogue of Cook-Levin. Understand NL-completeness of graph reachability (ST-Connectivity) and how the Immerman-Szelepcsényi theorem shows NL = co-NL.

Common Misconceptions

Explainer

From your study of time complexity, you know that P and NP classify problems by how much *time* a Turing machine needs. Space complexity asks a different question: how many tape cells does the machine use? This shift in resource leads to a different — and in some ways richer — hierarchy of complexity classes, because space can be reused (you can overwrite a tape cell) while time cannot be recovered.

PSPACE contains all problems solvable using a polynomial amount of memory, regardless of how long the computation takes. Its complete problem is TQBF (True Quantified Boolean Formulas): given a Boolean formula with alternating universal and existential quantifiers, determine whether it is true. Think of TQBF as a two-player game — one player tries to make the formula true, the other tries to make it false, and they alternate choosing variable assignments. This game-theoretic flavor is characteristic of PSPACE problems: evaluating game positions, planning under adversarial conditions, and verifying properties of systems with alternating control all tend to land in PSPACE. We know P ⊆ NP ⊆ PSPACE ⊆ EXPTIME, but whether any of these containments are strict remains open.

At the other end of the space spectrum, L (logarithmic space) contains problems solvable using only O(log n) bits of working memory beyond the read-only input. This is barely enough to store a constant number of pointers into the input. NL (nondeterministic log space) allows nondeterministic guessing on that same tiny workspace. The canonical NL-complete problem is ST-Connectivity: given a directed graph, is there a path from s to t? A nondeterministic machine can guess the path one node at a time, needing only enough memory to store the current node. A remarkable result — the Immerman-Szelepcsényi theorem — shows that NL = co-NL, meaning if you can nondeterministically verify reachability, you can also nondeterministically verify *non*-reachability in log space.

The most surprising structural result is Savitch's theorem: NSPACE(f(n)) ⊆ DSPACE(f(n)²). This means nondeterminism gives at most a quadratic advantage in space, unlike the potentially exponential advantage it might give in time (the P vs NP question). The proof is elegant — it uses a recursive divide-and-conquer strategy to check whether a configuration is reachable in 2k steps by checking whether some midpoint configuration is reachable in 2k-1 steps from both ends. As an immediate corollary, NPSPACE = PSPACE, collapsing the nondeterministic and deterministic polynomial-space classes together. This contrasts sharply with time complexity, where NP and P are widely believed to differ.

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 → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Two-Way Finite Automata → NFA to DFA Conversion (Subset Construction) → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Pushdown Automata (PDA) → Equivalence of CFGs and Pushdown Automata → Closure Properties of Context-Free Languages → Limitations of Context-Free Languages → Pumping Lemma for Context-Free Languages → Turing Machines → Variants of Turing Machines and Equivalence → Nondeterministic Time Complexity and NP → Space Complexity: PSPACE, L, and NL

Longest path: 95 steps · 495 total prerequisite topics

Prerequisites (4)

Leads To (4)