Comp2230: Design and Analysis of Algorithms
Fall 2007
Tutorial 7: NP Completeness
Question 1: The subgraph isomorphism problem takes two graphs G 1and G 2 and ask
whether G 1is a subgraph of G
2. Prove that the subgraph isomorphism problem is
NP-complete. (Hints: Reduce from a problem we have shown in class to be
NP-complete.)
Solution:
1
2
Question 2: Define the optimization problem LONGEST-PATH-LENGTH as the
relation that associates each instance of an undirected graph and two vertices with the
number of edges in the longest simple path between the two vertices.
Define the decision problem LONGEST-PATH = {< G, u, v, k >: G = (V, E) is an
undirected graph, u, v ∈ V, k ≥ 0 is an integer, and there exists a simple path from u to v
in G consisting of at least k edges}.
Show that the optimization problem LONGEST-PATH-LENGTH can be solved in
polynomial time IF AND ONLY IF LONGEST-PATH∈ P.
Solution:
3
4
© Copyright 2026 Paperzz