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

Complexity Class NP: Nondeterministic Polynomial Time

Graduate Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
75topics build on this
498prerequisites beneath it
See this on the map →
Complexity Class P: Polynomial TimeAsymptotic Notation: Big-O, Big-Omega, Big-Theta+1 more→→Algorithmic Game TheoryBQP and Quantum Complexity Classes+6 more
np-class nondeterminism verification certificate hard

Core Idea

NP contains languages decided by nondeterministic TMs in polynomial time. Equivalently, NP is languages where yes-instances admit polynomial-size certificates verifiable in polynomial time. Many practical hard problems (SAT, clique, TSP decision version) are NP. The P vs NP question asks: is guessing-and-checking as fast as deterministic solving? Most believe P ≠ NP, but it remains open.

Explainer

You already know that P contains problems solvable in polynomial time by a deterministic Turing machine. NP — nondeterministic polynomial time — captures a broader and more subtle idea: problems where proposed solutions can be *verified* efficiently, even if finding them from scratch might be hard. The formal definition says a language is in NP if a nondeterministic Turing machine can decide it in polynomial time. A nondeterministic TM can "guess" at each step, exploring many computational paths simultaneously. If *any* path leads to acceptance within polynomial steps, the machine accepts.

But the more intuitive and practically useful characterization is the verifier definition. A language L is in NP if there exists a polynomial-time deterministic TM (called a verifier) and a constant *c* such that for every string *x* in L, there exists a certificate (also called a witness) of length at most |*x*|^*c* that the verifier can check to confirm *x* ∈ L. Think of it like a jigsaw puzzle: finding the solution may take an enormous amount of trial and error, but if someone hands you the completed puzzle, you can quickly verify it's correct by checking that all pieces fit. The completed puzzle is the certificate.

Consider the problem CLIQUE: given a graph G and a number k, does G contain a complete subgraph of k vertices? This is in NP because if someone claims the answer is "yes" and hands you k specific vertices as the certificate, you can verify in polynomial time that every pair of those vertices is connected by an edge. You don't need to search through all possible subsets — you just check the proposed solution. Similarly, for SAT (Boolean satisfiability), a certificate is a specific truth assignment to all variables; verifying that it satisfies every clause takes linear time in the formula length.

Every problem in P is automatically in NP — if you can *solve* a problem in polynomial time, you can certainly *verify* a solution in polynomial time (just solve it yourself and compare). So P ⊆ NP. The monumental open question is whether this containment is strict: does P = NP? If P = NP, then every problem whose solutions can be efficiently verified can also be efficiently solved — a staggering collapse that would break most of modern cryptography and solve countless optimization problems overnight. Most computer scientists believe P ≠ NP, meaning there exist problems where checking is fundamentally easier than finding. But despite decades of effort, no one has proven this. The P vs NP question is one of the seven Millennium Prize Problems, with a million-dollar bounty for its resolution.

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 → The P vs. NP Problem → Complexity Class P: Polynomial Time → Complexity Class NP: Nondeterministic Polynomial Time

Longest path: 97 steps · 498 total prerequisite topics

Prerequisites (3)

Leads To (8)