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

Nondeterministic Polynomial Time and NP

College Depth 93 in the knowledge graph ☐ I know this ☆ Set as goal
11topics build on this
497prerequisites beneath it
See this on the map →
NP and Polynomial-Time VerificationNondeterministic Turing Machines+1 more→→Boolean Satisfiability and Standard NP-Complete ProblemsThe Polynomial Hierarchy Beyond NP+1 more
NP nondeterminism complexity-classes

Core Idea

NP is the class of languages recognized by nondeterministic Turing machines in polynomial time, or equivalently, languages with polynomial-time verifiers: for membership x ∈ L, a short certificate exists that can be verified in polynomial time. This characterization makes NP capture optimization and constraint-satisfaction problems; P ⊆ NP, and whether they are equal is the P vs NP problem.

Explainer

You already know about deterministic polynomial time (P) and nondeterministic Turing machines. The class NP arises naturally when you combine them: it is the set of languages recognized by a nondeterministic Turing machine (NTM) running in polynomial time. A nondeterministic machine at each step can branch into multiple computation paths simultaneously, and it *accepts* an input if any single branch accepts. When we say NP allows polynomial time, we mean every accepting branch has polynomial length — the machine may spawn exponentially many branches, but each individual branch is short.

The second characterization — the verifier definition — is often more intuitive and reveals why NP is natural. A language L is in NP if there exists a polynomial-time algorithm V (the verifier) and a polynomial p such that: x ∈ L if and only if there exists a certificate (witness) c with |c| ≤ p(|x|) where V(x, c) = 1. The certificate is short evidence that x belongs to L. For graph 3-colorability, the certificate is a valid coloring; for the Hamiltonian cycle problem, it is the cycle itself; for satisfiability, it is a satisfying assignment. The verifier checks the certificate in polynomial time — quickly, once it has the answer in hand. The two definitions are provably equivalent: the nondeterministic machine "guesses" the certificate on one branch and then verifies it deterministically.

Why does this capture so many natural problems? Because optimization and constraint-satisfaction problems nearly always have the structure "Does there exist a solution satisfying these constraints?" — and when a solution exists, it is a short certificate. Scheduling, integer programming, graph problems, protein folding, circuit layout: all fit this template. The certificate makes the "yes" side easy to witness, even if finding the certificate seems hard.

P ⊆ NP because a deterministic polynomial-time algorithm is a degenerate nondeterministic one with no branching. Whether P = NP — whether every problem whose solution is easy to *verify* is also easy to *find* — is the central open question in theoretical computer science. Most researchers believe P ≠ NP, but no proof exists. A resolution would reshape cryptography (whose security assumes certain problems are easy to verify but hard to solve), artificial intelligence, and mathematics itself. NP is the formal container for this question.

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 → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → 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 → Opposites and Additive Inverses → 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 → Natural Numbers in Set Theory: Iterative Construction → Formal Arithmetic and Expressibility → Turing Machines → Time Complexity and the Class P → Nondeterministic Turing Machines → NP and Polynomial-Time Verification → Nondeterministic Polynomial Time and NP

Longest path: 94 steps · 497 total prerequisite topics

Prerequisites (3)

Leads To (3)