CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
CSE 421 Algorithms
-
Upload
eve-alford -
Category
Documents
-
view
12 -
download
0
description
Transcript of CSE 421 Algorithms
![Page 1: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/1.jpg)
CSE 421Algorithms
Richard Anderson
Lecture 29
NP-Completeness
![Page 2: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/2.jpg)
Sample Problems
• Independent Set– Graph G = (V, E), a subset S of the vertices is
independent if there are no edges between vertices in S
1
3
2
6 7
4 5
![Page 3: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/3.jpg)
Satisfiability
• Given a boolean formula, does there exist a truth assignment to the variables to make the expression true
![Page 4: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/4.jpg)
Definitions
• Boolean variable: x1, …, xn
• Term: xi or its negation !xi
• Clause: disjunction of terms– t1 or t2 or … tj
• Problem:– Given a collection of clauses C1, . . ., Ck, does
there exist a truth assignment that makes all the clauses true
– (x1 or !x2), (!x1 or !x3), (x2 or !x3)
![Page 5: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/5.jpg)
3-SAT
• Each clause has exactly 3 terms
• Variables x1, . . ., xn
• Clauses C1, . . ., Ck
– Cj = (tj1 or tj2 or tj3)
• Fact: Every instance of SAT can be converted in polynomial time to an equivalent instance of 3-SAT
![Page 6: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/6.jpg)
Theorem: 3-SAT <P IS
• Build a graph that represents the 3-SAT instance• Vertices yi, zi with edges (yi, zi)
– Truth setting
• Vertices uj1, uj2, and uj3 with edges (uj1, uj2), (uj2,uj3), (uj3, uj1)– Truth testing
• Connections between truth setting and truth testing:– If tjl = xi, then put in an edge (ujl, zi)– If tjl = !xi, then put in an edge (ujl, yi)
![Page 7: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/7.jpg)
Example
C1 = x1 or x2 or !x3
C2 = x1 or !x2 or x3
C3 = !x1 or x2 or x3
![Page 8: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/8.jpg)
Thm: 3-SAT instance is satisfiable iff there is an IS of size n + k
![Page 9: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/9.jpg)
What is NP?
• Problems solvable in non-deterministic polynomial time . . .
• Problems where “yes” instances have polynomial time checkable certificates
![Page 10: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/10.jpg)
Certificate examples
• Independent set of size K– The Independent Set
• Satifisfiable formula– Truth assignment to the variables
• Hamiltonian Circuit Problem– A cycle including all of the vertices
• K-coloring a graph– Assignment of colors to the vertices
![Page 11: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/11.jpg)
NP-Completeness
• A problem X is NP-complete if – X is in NP
– For every Y in NP, Y <P X
• X is a “hardest” problem in NP
• If X is NP-Complete, Z is in NP and X <P Z
– Then Z is NP-Complete
![Page 12: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/12.jpg)
Cook’s Theorem
• The Circuit Satisfiability Problem is NP-Complete
![Page 13: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/13.jpg)
Garey and Johnson
![Page 14: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/14.jpg)
History
• Jack Edmonds– Identified NP
• Steve Cook– Cook’s Theorem – NP-Completeness
• Dick Karp– Identified “standard” collection of NP-Complete
Problems
• Leonid Levin– Independent discovery of NP-Completeness in USSR
![Page 15: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/15.jpg)
Populating the NP-Completeness Universe
• Circuit Sat <P 3-SAT• 3-SAT <P Independent Set• Independent Set <P Vertex Cover• 3-SAT <P Hamiltonian Circuit• Hamiltonian Circuit <P Traveling Salesman• 3-SAT <P Integer Linear Programming• 3-SAT <P Graph Coloring• 3-SAT <P Subset Sum• Subset Sum <P Scheduling with Release times
and deadlines
![Page 16: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/16.jpg)
Hamiltonian Circuit Problem
• Hamiltonian Circuit – a simple cycle including all the vertices of the graph
![Page 17: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/17.jpg)
Traveling Salesman Problem
• Given a complete graph with edge weights, determine the shortest tour that includes all of the vertices (visit each vertex exactly once, and get back to the starting point)
1
2
4
2
3
5
4
77
1
![Page 18: CSE 421 Algorithms](https://reader035.fdocuments.net/reader035/viewer/2022072015/56813000550346895d95766a/html5/thumbnails/18.jpg)
Thm: HC <P TSP