Presentation is loading. Please wait.

Presentation is loading. Please wait.

NP-Completeness (36.4-5/34.4-5)

Similar presentations


Presentation on theme: "NP-Completeness (36.4-5/34.4-5)"— Presentation transcript:

1 NP-Completeness (36.4-5/34.4-5)
P: yes and no in pt NP: yes in pt NPH  NPC NP-hard NPC P NP

2 Satisfiability Boolean formulas: x, (x  y) (x  y) (xy) (xy)
Satisfiability Problem (SP): given a Boolean formula is there any 0-1 input (0-1 assignment to variables) s.t. formula is true (=1)? Cook’s Theorem: SP is NP-complete. SP is an NP-problem (why?) SP is NP-hard (w/o proof)

3 (l11  l12 ... l1s1) ...  (ln1  ln2 ... lnsn)
3-CNF Conjunctive normal form (CNF) = (l11  l12 ... l1s1) ...  (ln1  ln2 ... lnsn) each literal l is either variable or negation 3-CNF: each si=3 3-CNF Satisfiability is NPC (x1 x2)  (x1   x4 ) Corresponding tree y3(y1  (x1  x2)) (y2  ( x1   x4 )) Truth assignment for each clause using tables. y3 y1 y2  x1 x2 x1  x4

4 Independent Set x z y’ x’ z’ a a’ x y x, z’, y independent
Independent set in a graph G: pairwise nonadjacent vertices Max Independent Set is NPC Is there independent set of size k? Construct a graph G: literal -> vertex two vertices are adjacent iff they are in the same clause they are negations of each other 3-CNF with k clauses is satisfiable iff G has independent k-set assign 1’s to literals-vertices of independent set Example: f = (x+z+y’) & (x’+z’+a) & (a’+x+y) x z y’ x’ z’ a a’ x y x, z’, y independent F is satisfiable: f = 1 if x = z’ = y = 1

5 MAX Clique G Complement G’ Max Clique (MC): MC is in NP MC is in NPC
Find the maximum number of pairwise adjacent vertices MC is in NP for the answer yes there is certificate of polynomial length = clique which can be checked in polynomial time MC is in NPC Polynomial time reduction from MIS: For any graph G any independent set in G 1-1 corresponds to clique in the complement graph G’ red independent set red clique G noedge  edge edge  noedge Complement G’

6 Minimum Vertex Cover Vertex Cover: Minimum Vertex Cover (MVC):
the set of vertices which has at least one endpoint in each edge Minimum Vertex Cover (MVC): MIN Vertex Cover is NPC If C is vertex cover, then V - C is an independent set red independent set blue vertex cover

7 Set Cover d a b c A B A = {a,b,c}, B = {c,d}
Given: a set X and a family F of subsets of X, F  2X, s.t. X covered by F Find : subfamily G of F such that G covers X and |G| is minimize Set Cover is NPC reduction from Vertex Covert Graph representation: edge between set A F and element x  X means x  A d a b c red elements of ground set X blue subsets in family F A B A = {a,b,c}, B = {c,d}

8 Intermediate Classes NP-hard NPC Dense Set Cover is NP but not in P
neither in NPC Dense Set Cover: Each element of X belongs to at least half of all sets in F

9 Runtime Complexity Classes
Runtime order: constant almost constant logarithmic sublinear linear pseudolinear quadratic polynomial subexponential exponential superexponential Example adding an element in a queue/stack inverse Ackerman function = O(loglog…log n) n times extracting minimum from binary heap n1/2 traversing binary search tree, list O(n log n) sorting n numbers, closest pair, MST, Dijkstra shortest paths adding two nn matrices e n ^ (1/2) e n, , n! Ackerman function 2 . n times


Download ppt "NP-Completeness (36.4-5/34.4-5)"

Similar presentations


Ads by Google