Presentation is loading. Please wait.

Presentation is loading. Please wait.

NPC.

Similar presentations


Presentation on theme: "NPC."— Presentation transcript:

1 NPC

2 Millennium Prize Problems
Poincare (pon car re)

3 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".

4 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 non-deterministic machine in polynomial time is called a problem in NP. Is Towers of Hanoi problem in NP?

5 NPC

6 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 Is it in P?  Determine the graph is a bipartite graph or not

7 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?

8 3-Coloring

9 3-Coloring Is 3-coloring problem in NP ? Yes Is it in P?

10 3-Coloring Is 3-coloring problem in NP ? Yes It is in NPC

11 4-coloring Four color conjecture – a planar map can be colored properly using 4 colors.

12 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

13 Hamilton cycle problem
a simple cycle contains all vertices Hamilton cycle problem: Does a given undirected graph have a Hamilton cycle ? Is Hamilton cycle problem in NP? Yes

14 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?

15 Vertex Cover 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, uC or vC. 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. A C B D B D

16 Vertex Cover Is vertex cover problem in NP ? Yes

17 (xy)(yz)(xz)(zy)
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: 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. (xy)(yz)(xz)(zy)

18 (xy)(yz)(xz)(zy)
exercise (x  y) (xz) (xy)(yz)(xz)(zy)

19 kSAT P NP-hard Maximal number of literals per clause 4 3 2 1

20 2SAT is in P Theorem: 2SAT is polynomial-time decidable.
Proof: using path searches (DFS/BFS) in graphs…

21 Graph Construction Vertex for each variable and a negation of the variable Edge (,) iff there exists a clause equivalent to ()

22 Graph Construction: Example
(xy)(yz)(xz)(zy) More edges? x Note: xy  yx y x y z z

23 Observation Claim: If the graph contains a path from  to , it also contains a path from  to . Proof: If there’s an edge (,), then there’s also an edge (,).

24 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

25 Graph Construction: Example
(xy)(yz)(xz)(zy)(zx) x y x y z z

26 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! x x T T F F

27 Only IF 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 x y x z z y x 2. assign T to all reachable vertices y x 3. assign F to their negations y z 4. Repeat until all vertices are assigned z

28 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.

29 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

30 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  2SATP.

31 3SAT Is E satisfiable? 3SAT is in NP – a decision problem that can be solved in nondeterministic polynomial time

32

33 Final review


Download ppt "NPC."

Similar presentations


Ads by Google