Docsity

NP Completeness: Understanding Reductions and NP-Hard/Complete Problems, Slides of Computer Science

Partial preview of the text

Download NP Completeness: Understanding Reductions and NP-Hard/Complete Problems and more Slides Computer Science in PDF only on Docsity!

Algorithms

NP Completeness Continued:

Reductions

Homework 7

● Check the web later today…

■ Change in grading policy: drop lowest hw

Review: Reduction

● A problem P can be reduced to another problem

Q if any instance of P can be rephrased to an

instance of Q, the solution to which provides a

solution to the instance of P

■ This rephrasing is called a transformation

● Intuitively: If P reduces in polynomial time to

Q, P is “no harder to solve” than Q

Review: NP-Hard and NP-Complete

● If P is polynomial-time reducible to Q, we

denote this P ≤p Q

● Definition of NP-Hard and NP-Complete:

■ If all problems R ∈ NP are reducible to P, then P is NP-Hard ■ We say P is NP-Complete if P is NP-Hard and P ∈ NP

● If P ≤p Q and P is NP-Complete, Q is also

NP- Complete

Directed Hamiltonian Cycle ⇒ Undirected Hamiltonian Cycle

● What was the hamiltonian cycle problem

again?

● For my next trick, I will reduce the directed

hamiltonian cycle problem to the undirected

hamiltonian cycle problem before your eyes

■ Which variant am I proving NP-Complete?

● Draw a directed example on the board

■ What transformation do I need to effect?

Transformation: Directed ⇒ Undirected Ham. Cycle

● Transform graph G = (V, E) into G’ = (V’, E’):

■ Every vertex v in V transforms into 3 vertices v^1 , v^2 , v^3 in V’ with edges ( v^1 , v^2 ) and ( v^2 , v^3 ) in E’ ■ Every directed edge ( v , w ) in E transforms into the undirected edge ( v^3 , w^1 ) in E’ (draw it) ■ Can this be implemented in polynomial time? ■ Argue that a directed hamiltonian cycle in G implies an undirected hamiltonian cycle in G’ ■ Argue that an undirected hamiltonian cycle in G’ implies a directed hamiltonian cycle in G

Hamiltonian Cycle ⇒ TSP

● The well-known traveling salesman problem :

■ Optimization variant: a salesman must travel to n cities, visiting each city exactly once and finishing where he begins. How to minimize travel time? ■ Model as complete graph with cost c( i,j ) to go from city i to city j

● How would we turn this into a decision

problem?

■ A: ask if ∃ a TSP with cost < k

Hamiltonian Cycle ⇒ TSP

● The steps to prove TSP is NP-Complete:

■ Prove that TSP ∈ NP ( Argue this ) ■ Reduce the undirected hamiltonian cycle problem to the TSP ○ So if we had a TSP-solver, we could use it to solve the hamilitonian cycle problem in polynomial time ○ How can we transform an instance of the hamiltonian cycle problem to an instance of the TSP? ○ Can we do this in polynomial time?