05

Computational Complexity

Chapter 5 • Advanced

60 min

Computational Complexity

Computational Complexity studies resource requirements of problems.

Complexity Classes

P (Polynomial Time)

P: Problems solvable in polynomial time by deterministic TM.

Examples:

  • Sorting
  • Shortest path
  • Matrix multiplication

NP (Nondeterministic Polynomial Time)

NP: Problems solvable in polynomial time by non-deterministic TM.

Equivalently: Problems with polynomial-time verifier.

Examples:

  • SAT (Boolean satisfiability)
  • Hamiltonian path
  • Clique

NP-Complete

NP-Complete: Problems in NP to which every NP problem reduces.

Properties:

  • In NP
  • All NP problems reduce to it

Examples:

  • SAT
  • 3-SAT
  • Clique
  • Vertex Cover
  • Hamiltonian Cycle

NP-Hard

NP-Hard: Problems to which all NP problems reduce.

May not be in NP.

Examples:

  • Halting problem
  • Optimization versions of NP-complete

P vs NP Problem

Open Question: Is P = NP?

If P = NP:

  • Many hard problems become easy
  • Cryptography breaks

If P ≠ NP:

  • Some problems inherently hard
  • Current understanding

Reduction

Polynomial-Time Reduction:

  • Problem A reduces to B in polynomial time
  • If B ∈ P, then A ∈ P
  • If A is NP-hard, then B is NP-hard

Use: Prove NP-completeness.

Cook-Levin Theorem

Cook-Levin Theorem: SAT is NP-complete.

Proof:

  • SAT ∈ NP (verifiable)
  • Every NP problem reduces to SAT
  • Therefore, SAT is NP-complete

Significance: First NP-complete problem.

Common NP-Complete Problems

  1. SAT: Boolean satisfiability
  2. 3-SAT: 3-CNF satisfiability
  3. Clique: Find clique of size k
  4. Vertex Cover: Find vertex cover of size k
  5. Hamiltonian Cycle: Find Hamiltonian cycle
  6. Traveling Salesman: TSP decision problem
  7. Subset Sum: Find subset summing to target

GATE CS Important Points

  1. P vs NP: Understand difference
  2. NP-Complete: Know examples
  3. Reduction: Use for NP-completeness proofs
  4. Cook-Levin: Understand significance
  5. Complexity Classes: Know hierarchy

Practice Tips

  1. Identify Complexity: Classify problems
  2. NP-Completeness: Prove using reduction
  3. Common Problems: Know NP-complete problems
  4. Reduction: Practice polynomial-time reductions
  5. Previous Year Questions: Solve GATE complexity questions