Ch8 NPC Millennium Prize Problems http://en.wikipedia.org/wiki/Millennium_Prize_Problems 8 NP-complete problem Hard problems: demo NP-hard (Non-deterministic Polynomial-time hard), in computational complexity theory, is a class of problems that are, informally, "at least ashard as the hardest problems in NP". NPC Informal Definition of NP Solutions to the problem can be verified easily (in polynomial time). The idea of “guessing” the right answer or checking all possible solutions in parallel to determine which is correct is called non-determinism. Any problem with an algorithm that runs on a nondeterministic machine in polynomial time is called a problem in NP. Is Towers of Hanoi problem in NP? 2-Coloring 2-coloring (2Col): Given a graph G, can each of its vertices be labeled with one of 2 different “colors”, such that no two adjacent vertices have the same label? Is 2-coloring problem in NP ? Yes Determine the graph is a Is it in P? bipartite graph or not Yes 1 3-Coloring 3-Coloring 3-coloring (3Col): Given a graph G, can each of its vertices be labeled with one of 3 different “colors”, such that no two adjacent vertices have the same label? 3-Coloring 3-Coloring Is 3-coloring problem in NP ? Yes Is it in P? Hamilton cycle problem 4-coloring Four color theorem – a planar map can be colored properly using 4 colors. The conjecture was first proposed in 1852 1970s, was proved with help from computer programs Is 3-coloring problem in NP ? Yes It is in NPC Hamilton cycle Hamilton cycle problem: a simple cycle contains all vertices Does a given undirected graph have a Hamilton cycle ? Is Hamilton cycle problem in NP? Yes 2 Vertex Cover Traveling salesman problem Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? Given a graph G, a vertex cover for G is a subset C of the vertices such that, for every edge (u,v) of G, uC or vC. The optimization goal is to find as small a vertex cover for G as possible. Vertex cover problem: Given a graph G and an integer k, determine whether there is a vertex cover for G containing at most k vertices. B B A D D C Vertex Cover 2SAT Often expressed as 2CNF (conjunctive normal form - a conjunction of clauses, where a clause is a disjunction of literals and there are n different literals) Ex: (xy)(yz)(xz)(zy) Is vertex cover problem in NP ? Yes The 2-satisfiability problem is to find a truth assignment to these variables that makes a formula of this type true. It’s a decision problem. exercise (x y) (xz) kSAT Maximal number of literals per clause P NP-hard (xy)(yz)(xz)(zy) 4 3 2 1 3 2SAT is in P Graph Construction Theorem: 2SAT is polynomial-time decidable. Vertex for each variable and a negation of the variable Proof: using path searches (DFS/BFS) in graphs… Edge (,) iff there exists a clause equivalent to () Graph Construction: Example (xy)(yz)(xz)(zy) Observation Claim: If the graph contains a path from to , it also contains a path from to . More edges? Note: xy yx x y x Proof: If there’s an edge (,), then there’s also an edge (,). y z z Corollary A 2-CNF formula is unsatisfiable iff there exists a variable x, such that: there is a path from x to x in the graph AND there is a path from x to x in the graph Graph Construction: Example (xy)(yz)(xz)(zy)(zx) x y x y z z 4 IF Only IF Suppose there are paths x..x and x..x for some variable x, AND there’s also a satisfying assignment . If (x)=T (similarly for (x)=F): () =? () is false! Suppose there are no such paths. Construct an assignment as follows: 1. pick an unassigned literal , with no path from to , and assign it T 2. assign T to all reachable vertices x yy xx x T . . . T x F F y z zz Only IF (2) Claim: The algorithm is well defined. Proof: If there were a path from x to both y and y, then there would have been a path from x to y and from y to x which indicate a path from x to x. 3. assign F to their negations 4. Repeat until all vertices are assigned Corollary Claim: a 2-CNF formula is unsatisfiable iff there exists a variable x, such that: there is a path from x to x in the graph AND there is a path from x to x in the graph 3SAT 2SAT is in P We get the following efficient algorithm for 2SAT: For each variable x find if there is a path from x to x and vice-versa. Reject if any of these tests succeeded. Accept otherwise 2SATP. Is E satisfiable? 3SAT is in NP – a decision problem that can be solved in nondeterministic polynomial time 5 6
© Copyright 2026 Paperzz