Presentation is loading. Please wait.

Presentation is loading. Please wait.

34.NP Completeness. Computer Theory Lab. Chapter 34P.2.

Similar presentations


Presentation on theme: "34.NP Completeness. Computer Theory Lab. Chapter 34P.2."— Presentation transcript:

1 34.NP Completeness

2 Computer Theory Lab. Chapter 34P.2

3 Computer Theory Lab. Chapter 34P.3

4 Computer Theory Lab. Chapter 34P.4 The subject of this chapter, however, is an interesting class of problems, called the “ NP-complete” problems, whose status is unknown. No polynomial-time algorithm has yet been discovered for an NP-computer problem, nor has anyone yet been able to prove that no polynomial-time algorithm can exist for any one of them. This so-called P ≠ NP question has been one of the deepest, most perplexing open research problems in theoretical computer science since it was first posed in 1971.

5 Computer Theory Lab. Chapter 34P.5

6 Computer Theory Lab. Chapter 34P.6 The difference between these problems Shortest vs. longest simple paths: Euler tour vs. hamiltonian cycle: 2-CNF satisfiability vs. 3 CNF satisfiablility NP-completeness and the classes P and NP Overview of showing problems to be NP- complete Decision problems vs. optimization problems

7 Computer Theory Lab. Chapter 34P.7 Reductions Suppose that there is a different decision problem, say B, that we already know how to solve in polynomial time. Finally, suppose that we have a procedure that transforms any instance  of A into some instance  of B with the following characteristics: 1.The transformation takes polynomial time. 2.The answer are the same. That is, the answer for  is “yes” if and only if the answer for  is also “yes.”

8 Computer Theory Lab. Chapter 34P.8 We can call such a procedure a polynomial-time reduction algorithm and, it provides us a way to solve problem A in polynomial time: 1.Given an instance  of problem A, use a polynomial- time reduction algorithm to transform it to an instance  of problem B. 2.Run the polynomial-time decision algorithm for B on the instance . 3.Use the answer for  as the answer for . Polynomial-time reduction algorithm Polynomial-time algorithm to decide A Polynomial-time Algorithm to decide B   yes no

9 Computer Theory Lab. Chapter 34P.9 A First NP-complete problem Because the technique of reduction relies on having a problem already known to be NP-complete in order to prove a different problem NP-complete, we need a “ first ” NPC problem. Circuit-satisfiability problem

10 Computer Theory Lab. Chapter 34P.10

11 Computer Theory Lab. Chapter 34P.11

12 Computer Theory Lab. Chapter 34P.12

13 Computer Theory Lab. Chapter 34P.13

14 Computer Theory Lab. Chapter 34P.14

15 Computer Theory Lab. Chapter 34P.15

16 Computer Theory Lab. Chapter 34P.16

17 Computer Theory Lab. Chapter 34P.17

18 Computer Theory Lab. Chapter 34P.18

19 Computer Theory Lab. Chapter 34P.19

20 Computer Theory Lab. Chapter 34P.20

21 Computer Theory Lab. Chapter 34P.21

22 Computer Theory Lab. Chapter 34P.22

23 Computer Theory Lab. Chapter 34P.23

24 Computer Theory Lab. Chapter 34P.24

25 Computer Theory Lab. Chapter 34P.25

26 Computer Theory Lab. Chapter 34P.26

27 Computer Theory Lab. Chapter 34P.27

28 Computer Theory Lab. Chapter 34P.28

29 Computer Theory Lab. Chapter 34P.29

30 Computer Theory Lab. Chapter 34P.30

31 Computer Theory Lab. Chapter 34P.31

32 Computer Theory Lab. Chapter 34P.32

33 Computer Theory Lab. Chapter 34P.33

34 Computer Theory Lab. Chapter 34P.34

35 Computer Theory Lab. Chapter 34P.35

36 Computer Theory Lab. Chapter 34P.36

37 Computer Theory Lab. Chapter 34P.37

38 Computer Theory Lab. Chapter 34P.38

39 Computer Theory Lab. Chapter 34P.39

40 Computer Theory Lab. Chapter 34P.40

41 Computer Theory Lab. Chapter 34P.41

42 Computer Theory Lab. Chapter 34P.42

43 Computer Theory Lab. Chapter 34P.43

44 Computer Theory Lab. Chapter 34P.44

45 Computer Theory Lab. Chapter 34P.45

46 Computer Theory Lab. Chapter 34P.46

47 Computer Theory Lab. Chapter 34P.47

48 Computer Theory Lab. Chapter 34P.48

49 Computer Theory Lab. Chapter 34P.49

50 Computer Theory Lab. Chapter 34P.50

51 Computer Theory Lab. Chapter 34P.51

52 Computer Theory Lab. Chapter 34P.52

53 Computer Theory Lab. Chapter 34P.53

54 Computer Theory Lab. Chapter 34P.54

55 Computer Theory Lab. Chapter 34P.55

56 Computer Theory Lab. Chapter 34P.56

57 Computer Theory Lab. Chapter 34P.57

58 Computer Theory Lab. Chapter 34P.58

59 Computer Theory Lab. Chapter 34P.59 34.5 NP-Complete Problems

60 Computer Theory Lab. Chapter 34P.60

61 Computer Theory Lab. Chapter 34P.61

62 Computer Theory Lab. Chapter 34P.62

63 Computer Theory Lab. Chapter 34P.63

64 Computer Theory Lab. Chapter 34P.64

65 Computer Theory Lab. Chapter 34P.65

66 Computer Theory Lab. Chapter 34P.66

67 Computer Theory Lab. Chapter 34P.67

68 Computer Theory Lab. Chapter 34P.68

69 Computer Theory Lab. Chapter 34P.69

70 Computer Theory Lab. Chapter 34P.70

71 Computer Theory Lab. Chapter 34P.71

72 Computer Theory Lab. Chapter 34P.72

73 Computer Theory Lab. Chapter 34P.73 Theorem 34.13 The hamiltonian cycle problem is NP- complete.

74 Computer Theory Lab. Chapter 34P.74 Proof. First, show that HAM-CYCLE belongs to NP. We now prove that VERTEX-COVER  p HAM- CYCLE, which shows that HAM-CYCLE is NP- complete. Given an undirected graph G=(V,E) and an integer k, we construct an undirected graph G ’ =(V ’,E ’ ) that has a hamiltonian cycle iff G has a vertex cover of size k.

75 Computer Theory Lab. Chapter 34P.75 widget

76 Computer Theory Lab. Chapter 34P.76 The reduction of an instance of the vertex-cover problem to an instance of the hamiltonian-cycle problem. (a) An undirected graph G with a vertex of size 2, consisting if the lightly shaded vertices w and y. (b) the undirected graph G ’ produced by the reduction, with the hamiltonian path corresponding to the vertex cover shaded. The vertex cover {w,y} corresponds to edges (s 1,[w,x,1]) and (s 2,[y,x,1]) appearing in the hamiltonian cycle.

77 Computer Theory Lab. Chapter 34P.77

78 Computer Theory Lab. Chapter 34P.78 Three types of edges in E ’ 1. Edges in widget. 2. {([u,u (i),6],[u,u (i+1),1]) : 1  i  degree(u)-1} 3. {(s j,[u,u (1),1]) : u  V and 1  j  k}  {(s j,[u,u (degree(u)),6]) : u  V and 1  j  k}

79 Computer Theory Lab. Chapter 34P.79 The reduction performed in polynomial time |V ’ | = 12|E| + k  12|E| + |V| |E ’ | = (14|E|) + (2|E| -|V|) + (2k|V|) = 16|E| + (2k-1)|V|  16|E| + (2|V|-1)|V|

80 Computer Theory Lab. Chapter 34P.80 The transformation from graph G to G ’ is a reduction. That is, G has a vertex cover of size k iff G ’ has a hamiltonian cycle.

81 Computer Theory Lab. Chapter 34P.81

82 Computer Theory Lab. Chapter 34P.82

83 Computer Theory Lab. Chapter 34P.83 Theorem 34.15 The subset-sum problem is NP- complete.

84 Computer Theory Lab. Chapter 34P.84 Proof. First, show that SUBSET-SUM is in NP. We now show that 3-CNF-SAT  p SUBSET- SUM. Given a 3-CNF formula  over variables x 1, x 2, …, x n with clauses C 1, C 2, …, C k, each containing exactly three distinct literals. The reduction algorithm constructs an instance of the subset-sum problem such that  is satisfiable iff there is a subset of S whose sum is exactly t.

85 Computer Theory Lab. Chapter 34P.85 Example The formula in 3-CNF is  = C 1  C 2  C 3  C 4, where C 1 = (x 1  ¬ x 2  ¬ x 3 ), C 2 = ( ¬ x 1  ¬ x 2  ¬ x 3 ), C 3 = ( ¬ x 1  ¬ x 2  x 3 ), and C 4 = (x 1  x 2  x 3 ). A satisfying assignment of  is.

86 Computer Theory Lab. Chapter 34P.86 The reduction of 3-CNF-SAT to SUBSET-SUM C 4 has no ¬x 1 C 4 has x 2

87 Computer Theory Lab. Chapter 34P.87 The reduction performed in polynomial time The set S contains 2n+2k values, each of which has n+k digits, and the time to produce each digit is polynomial in n+k. The target t has n+k digits, and the reduction produces each in constant time.

88 Computer Theory Lab. Chapter 34P.88 3-CNF formula  is satisfiable iff there is a subset S ’  S whose sum is t.


Download ppt "34.NP Completeness. Computer Theory Lab. Chapter 34P.2."

Similar presentations


Ads by Google