Advanced Algorithms
Lesson 1 of 4 11 min +120 XP

P, NP & NP-Completeness

The frontier of efficient computation.

What you'll learn

  • Define the classes P and NP
  • Explain what NP-complete means
  • Understand a reduction
Easy to check, hard to solve

A finished jigsaw is instant to verify but agonizing to assemble from scratch. That gap — problems whose answers are quick to check (NP) but seemingly slow to find (P?) — is the heart of the P versus NP question, computing's biggest open mystery.

Easy to check vs. easy to solve

P is the class of problems solvable in polynomial time. NP is the class whose solutions can be verified in polynomial time. Every problem in P is in NP; whether P = NP is the central open question of computer science.

NP-complete

A problem is NP-complete if it's in NP and every NP problem reduces to it. Solve one NP-complete problem efficiently and you solve them all — so none is known to have an efficient algorithm.

Lab · Verify vs. solve
  1. Consider a filled-in Sudoku: is it easy to check it's valid?
  2. Consider a blank Sudoku: is it easy to solve?
  3. Match 'check' and 'solve' to verification and search.

What you should see: Checking a solution is fast (NP-style verification); finding one may be hard — the gap that P vs NP is about.

Knowledge Check

+30 XP / correct

1. NP is the class of problems whose solutions can be…

2. If any single NP-complete problem had a polynomial-time algorithm, then…