10 - Dealing with hard problems - NPC (Solution)

# 10 - Dealing with hard problems - NPC (Solution) - The Hong...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Tutorial 10: NP-Completeness Below is the solution to the tutorial questions. Question 1 : Given an undirected graph G = ( V, E ), a feedback vertex set is a subset of vertices such that every simple cycle of G passes through one of these vertices. The feedback vertex set problem (FVS) is, given a graph G and an integer k , does G contain a feedback vertex set of size at most k ? For example, the graph shown in the figure has a feedback vertex set of size 2 (shaded). Show that FVS is in NP. That is, given a graph G that has a FVS of size k , (a) Give a certificate for the FVS problem. Note: Certificate is a specific object which allows us to verify the given input (i.e. graph G ) is actually a yes-input. (b) Show how to use this certificate to verify the presence of a FVS. (Hint: Concentrate on the vertices that are not part of the FVS.) (c) Show the verification algorithm runs in polynomial time. Solution: (a) The certificate is the set V ′ of vertices that are in the feedback vertex set of size k . 1 (b) The verification algorithm needs to test whether every cycle in G passes through at least one of the vertices in V ′ . But, there are ex- ponentially many cycle in a graph! So, by testing each cycle would NOT run in polynomial time. Therefore, instead we can do something as follows. A new graph G ′ is constructed by deleting all the vertices in V ′ from G , along with any incident edges. Then, we notice that if every cycle in G passes through at least one of the vertices V ′ , there should have no cycle in G ′ anymore! The problem now is how to check whether there is any cycle in G ′ ! Well, we can do the checking by running DFS and see whether the resulting graph has AT LEAST ONE BACK EDGE or not. If so, V ′ is not a feedback vertex set (Since the cycle in G ′ does not pass through any vertex of V ′ ) and otherwise, it is! (c) Deleting all the vertices in V ′ from G along with any incident edges and running DFS to check whether there is any back edge can be performed in polynomial time....
View Full Document

## This note was uploaded on 10/18/2009 for the course COMP 271 taught by Professor Arya during the Spring '07 term at HKUST.

### Page1 / 9

10 - Dealing with hard problems - NPC (Solution) - The Hong...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online