Prove that set cover is NP-complete with a reduction from vertex
cover.
Set Cover
Input: a set X of n elements, a family F of subsets of X, and an
integer k.
Question: Does there exist k subsets from F whose union is X?
Vertex Cover
Input: A graph G = (V, E) and an integer k <= |V|.
Question: Is there a subset S of at most k vertices such that every edge
in E has at least one vertex in S?
First show the problem is in NP -
Given a solution of the set cover problem we can create an array
where each element in X has a corresponding element in the array.
Search through the subsets in F marking each element found in the
array. When finished searching through F, check if all elements were
found. This is on the order of O(# of subsets*|X|), and thus
polynomial in the input.
Second find a reduction from vertex cover to set
cover.
VertexCover(G=(V,E), k)
X = E
Create sets Si by adding in each edge adjacent to vertex
vi, for all vertices in G.
Let F be the collection of all the sets Si
Let k'=k
SetCover (X, F, k')
Last show that the reduction preserves the answers.
Assume that the graph G has a vertex cover with at most k
vertices. Call it set C. For each vertex in C, add the corresponding
set Si to the collection C'. Since every edge in G is
adjacent to a vertex in C, then C' must contain a subset that contains
that edge. Thus C' is a set cover for X and F with size k. Thus, there
is a set cover with k subsets.
Assume that a set cover for X and F exists with k subsets.
Then, the vertices that correspond to the subsets in the set cover
must also be a vertex cover. This follows since all the edges of the
graph are covered by the set cover.
Thus, the problem set cover is NP-complete.
page 160, Exercise 6.3 (5 points)
Prove that the baseball card collector problem is NP-hard.
Let X=the set of players and F be the collection of P1,
P2, ..., Pm. Then let k be the same k. This is
the set cover problem since a collection of packets that contains all of
the players is a set cover. Since set cover is NP-complete, the
baseball problem is also. Thus, it is NP-hard.
page 160, Exercise 6.5 (5 points)
Prove that the low degree spanning tree is NP-hard with a
reduction from Hamiltonian Path.
Low Degree Spanning Tree
Input: A graph G and an integer k.
Question: Does G contain a spanning tree such that all vertices in
the tree have degree at most k?
Hamiltonian Path
Input: A graph G = (V, E).
Question: Does there exist a path in G that contains all the vertices?
Reduction:
Ham Path (G)
Let G' = G
let k'=2
MinSpanTree(G', k')
Show the answers are equivalent:
Assume that there is a hamiltonian path in G. Take the
hamiltonian path to be the minimum degree spanning tree (since its
maximum degree is 2). Assume that there is a low degree spanning tree
of maximum degree 2, then it must be a hamiltonian path since its
spanning. Thus, the answers are equivalent.
Give an efficient algorithm to solve the high degree spanning tree
problem and an analysis of its time complexity.
Algorithm HighSpanTree(G, k):
Calculate di = degree of vertex i
let k'=max {di, i = 1, 2, ..., # of vertices}
if k <= k' return true, else return false
Analysis: Since it takes linear time (in # of edges + # of
vertices) to calculate the degrees and
linear time (in # of vertices) to find the maximum of the
ki's, it must take a linear time (in # of vertices and
edges) to run the algorithm.
Write a paragraph or two explaining how what you have learned in this
class will make you a better algorithm designer. You may use specific
examples if you need.