← Algorithm Design learning path
Algorithm Design · Module 9 of 10

Complexity classes

Understand P, NP and hard problems.

📖 Key ideas

  1. P: problems solvable in polynomial time.
  2. NP: solutions verifiable in polynomial time.
  3. NP-complete: hardest in NP (SAT, TSP decision, 3-colouring).
  4. NP-hard: at least as hard as NP-complete.
  5. P vs NP is a famous open problem.
💡 Real-life example: NP problems are jigsaw puzzles: checking a finished puzzle is easy, solving one may take forever.
PSolvable in polynomial time
NPVerifiable in polynomial time
NP-completeHardest problems in NP
ReductionTransforming one problem into another