Algorithm Design

Computational Complexity: P vs NP, Reductions & NP-Completeness

19:28

Plays from YouTube. Watch on YouTube

Why can we verify some solutions quickly, yet still struggle to find them?

Meet Computational Complexity: the mathematical framework for distinguishing efficient algorithms, efficiently verifiable certificates, and problems linked by reductions.

We start by comparing algorithms that run in polynomial time with decision problems like satisfiability and longest simple path. We define input size in bits, the classes P and NP, and what it really means to verify a proposed answer.

From there, we build polynomial-time reductions. The direction of the arrow matters: translating X to Y means a fast algorithm for Y would also solve X quickly. We use this logic to define NP-hardness and NP-completeness.

Then we explore Boolean circuits and SAT. Gate-equivalence clauses encode AND, OR, and NOT, allowing satisfiability of a circuit to be translated into formulas with clauses of at most three literals.

Next, we construct the classic reduction from Exact 3-SAT to Independent Set. Each clause becomes a triangle and contradictory literals are linked; selecting one consistent vertex per triangle is equivalent to satisfying the formula.

We extend the chain through Clique, Vertex Cover and Set Cover, then build an integer-digit reduction from Vertex Cover to Subset Sum. Large encoded numbers reveal why pseudopolynomial dynamic programming is not polynomial in the input bit length.

Finally, we discuss Hamiltonian Cycle and Path, demonstrate the tested vertex-splitting reduction, and summarize the obligations of a complete NP-completeness proof.

The big idea: hardness is established by careful, polynomial-size translations that preserve yes and no answers in both directions. The P versus NP question remains open.

Algorithms explained visually, one concept at a time.