Reductions and NP-completeness
도입됨
5:37
알고리즘 설계 및 분석
This course teaches you to price an algorithm's design before you trust it with real data. The first two units cover analysis tools and divide and conquer. The…
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| reduction/rɪˈdʌkʃn/ | 환원 |
| NP-complete/ˌen ˈpiː kəmˈpliːt/ | in NP and at least as hard as every problem in NP |
| NP-hard/ˌen ˈpiː hɑːd/ | at least as hard as every problem in NP, but not necessarily in NP itself |
| vertex cover/ˈvɜːteks ˈkʌvə/ | a set of vertices that touches every edge of a graph |
| approximation/əˌprɒksɪˈmeɪʃn/ | A value or representation close to the exact one and sufficiently accurate for a stated purpose. |
| certificate/səˈtɪfɪkət/ | a proposed solution that lets a "yes" answer be checked quickly |
| pseudo-polynomial/ˈsuːdəʊ ˌpɒlɪˈnəʊmɪəl/ | running time polynomial in the numeric value of the input, such as a capacity W, but exponential in the number of bits that write it |
One problem dressed as another
- A reduction 归约 $A \le_p B$ is a polynomial-time translator that turns instances of $A$ into instances of $B$ such that the output is a yes-instance exactly when the input is. A solver for $B$ then also solves $A$.
- A problem is NP-complete NP完全 if it is in NP and every problem in NP reduces to it.

A reduction A to B gives —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
The translator maps A-instances to B-instances: solving B solves A.
The two-step hardness proof
- To prove that $B$ is NP-hard NP难: pick a known NP-complete problem $A$ and build a polynomial translator from $A$ to $B$. The difficulty flows into your problem: you reduce the known hard problem to yours.
- The course chain passes the hardness along three links:
| Reduction | Translator |
|---|---|
| SAT → 3-SAT | split long clauses into 3-literal ones |
| 3-SAT → CLIQUE | one vertex per literal; join literals in different clauses that do not contradict |
| CLIQUE → VERTEX-COVER | take the complement graph |
- In the CLIQUE graph, a $k$-clique for $k$ clauses picks one literal per clause that can all be true together: a satisfying assignment.
To prove B NP-hard, reduce —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
The difficulty flows into your problem: known-hard TO yours.
The direction is the point
- Clique to cover, with real vertices: $G$ is the triangle ABC plus a vertex D with no edges. It has a 3-clique. The complement's edges are exactly A–D, B–D and C–D, and {D}, of size $n - k = 1$, covers them all.
- Reducing your problem to SAT proves nothing about hardness: the arrow points the easy way. NP means a yes-answer can be checked in polynomial time, and P is inside NP.
Encoding your problem as SAT proves —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
The arrow points the easy way: your problem reduces TO SAT.
Coping with hardness: approximation
- NP-hard does not mean hopeless. For vertex cover 顶点覆盖, take any edge that is not yet covered and add both of its ends; repeat.
- The chosen edges share no vertex, and any cover needs one end of each, so the result is at most twice the optimum (an approximation 近似 with factor 2).
- On the path A–B–C–D, if it takes A–B first and then C–D, it gets a cover of $4$, while the best is $\{B, C\}$, of size $2$: the factor $2$ can really happen. Exact search grows explosively: a symmetric travelling-salesman instance on $10$ cities has $9!/2 = 181\,440$ tours.
How many distinct tours does a symmetric travelling-salesman instance on 8 cities have?
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Fix the start and divide by 2 for direction: 7! / 2 = 2520.
The both-endpoints vertex-cover method can return a cover more than twice the optimum.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Its chosen edges share no vertex, and any cover needs one end of each, so it is at most twice optimal.
NP means a short certificate
- A problem is in NP when a claimed yes-answer (a certificate 证书) can be checked in polynomial time. For 3-colouring, the certificate is the colour of each vertex, and checking it means looking at every edge once: $\Theta(E)$.
- Finding a colouring may need exponential search; checking one is fast. The question P = NP asks whether every problem whose yes-certificates can be checked in polynomial time can also be solved in polynomial time.
Checking a claimed 3-colouring of a graph with $V$ vertices and $E$ edges takes:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Look at each edge once and compare its two colours.
Worked example: polynomial in what?
- The 0/1 knapsack DP fills $n \times W$ cells. With $n = 100$ and $W = 10^6$ that is $10^8$ cells, which is fine. But $W$ is written in only $\log_2 W \approx 20$ bits, so the cost is exponential in the length of the input.
- Such an algorithm is pseudo-polynomial 伪多项式. It does not show P = NP; it solves instances with polynomially bounded capacity in polynomial time.
Knapsack DP with $n = 100$ items and capacity $W = 10^6$: how many table cells?
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
$n \times W = 10^8$.
Bits needed to write $W = 10^6$ in binary?
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
$2^{20} = 1\,048\,576 > 10^6 > 2^{19}$.
Marks that slip away
- Reducing the wrong way. To show $B$ is hard, reduce a known hard $A$ to $B$; reducing $B$ to SAT shows nothing.
- Reading NP as "not polynomial". NP means a yes-answer can be checked in polynomial time, and P is inside NP.
- Giving up on an NP-hard problem. Vertex cover has a factor-2 approximation, and small instances can still be solved exactly.
Recap
- $A \le_p B$: a polynomial translator from instances of A to instances of B.
- To prove B hard, reduce a known NP-complete problem to B, never the other way.
- A clique of size $k$ in $G$ gives a vertex cover of size $n - k$ in the complement.
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.