Download presentation

Presentation is loading. Please wait.

Published byTyree MacKenzie Modified about 1 year ago

1
NP and NP Complete

2
Definitions A problem is in the class P if there is a polynomial time solution to the problem A problem is in the class NP if there is a non- deterministic polynomial time solution to the problem –Essentially, given a solution, can you determine if it works in polynomial time A problem is in the class NP-Hard if every problem in NP reduces to it –What does it mean for one problem to reduce to another? A problem is in the class NP-Complete if it is both NP and NP-Hard

3
Cook's Theorem SAT is NP-Complete –Clearly in NP SAT – Given a boolean expression, it is satisfiable if there exists an assignment of 0s and 1s to its variables such that the expression evaluates to 1 –(x|y)&(x|y) –(x|y)&(!x|y)&(!y)

4
Cook's Theorem SAT is NP-Complete –Clearly in NP SAT – Given a boolean expression, it is satisfiable if there exists an assignment of 0s and 1s to its variables such that the expression evaluates to 1 –(x|y)&(x|y) – x=T y=T or x=T y=F or x=F y=T –(x|y)&(!x|y)&(!y) – ???

5
Clique Given an undirected graph G=(V, E) and an integer k, determine whether G contains a clique of size >=k. –Clique – a subgraph such that all vertices are connected to all other vertices Clique is in NP – given a subset of >= k vertices, easy to determine if subset represents a clique

6
Reduce SAT to Clique Show how to create an instance of Clique to represent any SAT problem –if you can solve the Clique problem, you can solve SAT Given an expression in conjunctive normal form, create a column of vertices for each clause Connect each vertex to all other vertices that are not in same column and are not the complement

7
Example (Manber text) E=(x|y|!z)&(!x|!y|z)&(y|!z) x y !z !x !y z y !z Choose k as m (number of clauses) If clique of size k, it must contain one vertex from every column since vertices in a column do not connect Assign value of 1 to each variable represented by vertex in clique(x and !x not connected) – solution to SAT!

8
TSP Hamiltonian Cycle (HAM) –Find a simple cycle, in an undirected graph, that visits every vertex. TSP –Given a complete graph G=(V, E), with edge costs, and an integer K, is there a simple cycle that visits all vertices and has total cost <= K?

9
TSP NP

10
TSP NP – Given a simple cycle, in polynomial time can check if it contains all vertices and has cost <= K. Reduce HAM to TSP –solve HAM using a solution to TSP –create an instance of TSP to represent any HAM

11
TSP – NP-Complete Determine if Hamiltonian Cycle exists for G. Create complete graph G' that has same vertices as in G. Edge has weight 1 if it is in G and 2 otherwise. Solve TSP on G' with K = number of vertices. TSP tour that visits all vertices will contain each vertex 1 time and will use only edges of weight 1

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google