In Monday's lecture (based on KT Section 10.1) we saw that a particular NP-complete problem, VERTEX-COVER, has an algorithm that has a reasonable running time for small values of a particular parameter, the size of the vertex cover that is sought. This algorithm takes time O(2kkn) to determine whether an n-vertex graph has a vertex cover of size k -- this time is polynomial if k = O(log n).
In this discussion we will show that another NP-complete problem, HITTING-SET, has the same property. The input to HITTING-SET is a set A of n elements, a collection {B1, ..., Bm} of subsets of A, and a positive integer k. A set H ⊆ A is a hitting set for the B's if it contains at least one element of each Bi, that is, if H ∩ Bi ≠ ∅ for each i. The input is in the language HITTING-SET if there exists a hitting set for the B's of size k.
We are also interested in another parameter c, which is the maximum size of any of the sets Bi.
We first show that HITTING-SET is in NP. The input is in HITTING-SET if and
only if a hitting set exists, so we can define a certificate to simply be a
hitting set, a list of k elements of A. We accept the certificate if it has
size k and contains at least one element of each Bi -- to test this
we take each of the m sets and check each of the n elements to see whether it
is in the list (until we find one or run out of elements). This takes
O(ckm) time, and since c ≤ n and k ≤ n we have O(mn2) time,
which is polynomial.
Our reduction is from VERTEX-COVER. Given an undirected graph G of n nodes
and m edges and a parameter k, we define A to be the set of nodes in G, we
define Bi to be the set of the two endpoints of edge ei,
and let the parameter k be the same k we are given. Then G has a vertex
cover of size k if and only if our A has a hitting set of size k for the B's.
This is because a set of nodes in G is a vertex cover if and only if it "hits"
(has an element in common with) each of the edges.
This reduction is computable in polynomial time because we merely have to
list the edges of G in a different format and need only O(n+m) time. Since
a known NP-complete problem reduces to HITTING-SET and HITTING-SET is in NP,
it is NP-complete.
Now we would like to show that HITTING-SET is fixed-parameter tractable, as in KT Exercise 10.1 -- this means that the running time is an arbitrary function of k and c times a polynomial function of m and n. As in the VERTEX-COVER problem, it may be useful to think how you would solve the problem for k=1, k=2, etc., with c taken to be a constant.
If k=1, we need to know whether there is a single element that is common to
all the B's. If there is such an element, it must be one of the elements of
B1, of which there are at most c. Thus in O(cm) time we can check
each of the elements of Bi for membership in each of the other B's,
and thus decide whether there is a one-element hitting set.
If k=2, we need to find a two-element set, and again we know that one of
the elements (at least) must be in B1. If x
is one of those c elements, we (a) make a subcollection of those B's (if any)
that do not contain x, and (b) recurse to the k=1 case to see if this
subcollection has a one-element hitting set. There is a two-element hitting
set for the B's if and only if for some x, there is a one-element hitting set
for the B's that don't contain x. Our k=2 algorithm requires us to try up to
c elements and spend O(cm) time on each, for a total running time of
O(c2m).
For general k, the idea above generalizes directly, so that for each element
of B1 we form a subcollection and then look for a hitting set of
size k-1 for the subcollection. Our total running time thus obeys the
recurrence T(k,m) ≤ c(T(k-1,m) + m), which has a solution of T(k,m) =
O(ckm). As desired, this is an arbitrary function of c and k,
ck, times a polynomial function of m, m itself.
Last modified 30 November 2006