4.6.26 · HinglishTheory of Computation

NP-complete problems — 3-SAT, Vertex Cover, Clique, Hamiltonian Path, TSP, Subset Sum

2,610 words12 min readRead in English

4.6.26 · Coding › Theory of Computation


NP-complete kya hai? (3 ingredients)

Reduction tool — Hardness kaise prove karte hain

Cook–Levin theorem (SAT is NP-complete) seed hai: yeh dikhata hai ki har NP problem SAT mein reduce hoti hai, seedha Turing-machine definition se. Uske baad, baaki saari problems ki hardness prove hoti hai pehle se proven NP-complete problem se reduce karke. Classic chain:

Figure — NP-complete problems — 3-SAT, Vertex Cover, Clique, Hamiltonian Path, TSP, Subset Sum

Problems ki cast (definitions jo tumhare paas honi chahiye)


Derivation 1 — Clique ↔ Vertex Cover ↔ Independent Set (easy trio)


Derivation 2 — 3-SAT Clique (famous gadget)


Derivation 3 — 3-SAT Subset Sum (number gadget)


Derivation 4 — Hamiltonian Cycle TSP


Common mistakes (Steel-man + fix)


Flashcards

NP ka full form aur matlab kya hai?
Nondeterministic Polynomial — ek certificate ko verify kiya ja sake polynomial time mein.
NP-complete define karo.
Ek problem jo NP mein bhi ho aur NP-hard bhi ho (har NP problem poly time mein isme reduce ho).
Problem ko NP-hard prove karne ke liye reduction kis direction mein hogi?
Ek known NP-complete problem ko mein reduce karo: .
kya guarantee karta hai?
jahan poly-time ho; ka fast solver ka bhi fast solver deta hai.
Kaunse theorem ne pehla NP-complete problem establish kiya?
Cook–Levin theorem (SAT is NP-complete).
Independent Set aur Vertex Cover ka relation?
size ka independent set size ka vertex cover hai.
Clique vs Independent Set ka link?
mein Clique complement graph mein Independent Set.
3-SAT→Clique mein do literal-vertices ke beech edge kab hoti hai?
Alag clauses mein hon AUR ek doosre ke negations na hon; clique size .
Subset Sum ka DP poly-time algorithm kyun nahi hai?
ke bits hain, isliye input length mein exponential ho sakta hai → pseudo-polynomial hai.
HamCycle→TSP mein kaunse edge weights aur budget use hote hain?
Weight 1 real edges ke liye, 2 baaki ke liye; budget (ek tour ek cycle hai jisme edges hain).
TSP budget kyun hai na ki ?
TSP tour ek cycle hai jo start par waapas aata hai, isliye edges hain, na ki path jaise .
Kya NP-complete aur undecidable same hai?
Nahi — NP-complete problems decidable hain (brute force terminate karta hai); bas (likely) poly-time mein nahi.
TSP ka decision form kya hai?
Weighted complete graph aur budget diya gaya ho, kya koi tour (cycle) hai jiska total cost ho?

Recall Feynman: 12-saal ke bacche ko explain karo

Ek bade group ke puzzles imagine karo — Sudoku, mazes, suitcase pack karna. Sab alag dikhte hain, lekin ek secret machine hai jo koi bhi ek puzzle ko doosre mein badal sakti hai. Toh yeh sab really ek hi bada puzzle hain alag-alag disguises mein. Hum inhe jaldi solve karne ka trick nahi jaante, lekin agar tumne ek solve kar liya, toh hum tumhara answer bahut jaldi check kar sakte hain. Aur sabse wild baat: agar kisi ne kabhi sirf ek ka fast trick dhundh liya, toh machine sabka fast trick turant de deti hai. Yeh disguised twins NP-complete kehlaate hain.

Connections

  • P vs NP — woh open million-dollar question jise yeh problems define karti hain.
  • Cook–Levin Theorem — saari NP-completeness proofs ka seed.
  • Polynomial-time Reductions — proof ki machinery.
  • Boolean Satisfiability (SAT, CNF) — reduction tree ki root.
  • Graph Theory — Cliques and Independent Sets
  • Dynamic Programming — Subset Sum / Knapsack (pseudo-polynomial).
  • Approximation Algorithms — jab exact solve karna hopeless ho toh hum kya karte hain (e.g. 2-approx Vertex Cover).
  • Undecidability and the Halting Problem — ek zyada strong type ki impossibility.

Concept Map

plus

both give

both give

proves

seeds chain

reduces to

reduces to

complement

links

reduces to

reduces to

reduces to

reduces to

NP - verify in poly time

NP-hard - all NP reduces to it

NP-complete

Poly-time reduction A le B

Cook-Levin - SAT NP-complete

SAT

3-SAT

Clique

Vertex Cover

Independent Set helper

Hamiltonian Cycle

TSP decision

Subset Sum