Skip to main content

This site is currently under development.

3. Set Cover

Acknowledgements

Some of this material is borrowed from Jeff Erickson's chapters on Recursion, Backtracking, and Dynamic Programming.

The Problem

Let F\mathcal{F} be a family of sets over a universe UU. For a subfamily F′⊆F\mathcal{F}^{\prime} \subseteq \mathcal{F} and a subset U′⊆UU^{\prime} \subseteq U, we say that F′\mathcal{F}^{\prime} covers U′U^{\prime} if every element of U′U^{\prime} belongs to some set of F′\mathcal{F}^{\prime}.

The Set Cover problem is the following:

  • The input is a family of sets F\mathcal{F} over a universe UU and a positive integer kk.

  • The task is to check whether there exists a subfamily F′⊆F\mathcal{F}^{\prime} \subseteq \mathcal{F} of size at most kk such that F′\mathcal{F}^{\prime} covers UU.

We describe here an algorithm for Set Cover that runs in time 2∣U∣(∣U∣+∣F∣)O(1)2^{|U|}(|U|+|\mathcal{F}|)^{\mathcal{O}(1)}. In fact, this algorithm does not use the value of kk, and finds the minimum possible cardinality of a family F′⊆F\mathcal{F}^{\prime} \subseteq \mathcal{F} that covers UU.

The Solution

What are the fragments (AKA, what do we want to store)?

Let us try projection again. Fix a subset X⊆UX \subseteq U and an integer 0⩽j⩽∣F∣0 \leqslant j \leqslant |\mathcal{F}|.

Define T[X,j]T[X, j] as the minimum possible size of a subset F′⊆{F1,F2,…,Fj}\mathcal{F}^{\prime} \subseteq\left\{F_1, F_2, \ldots, F_j\right\} that covers XX.

The TT's will be our fragments.

Are the fragments going to be useful (AKA, where is the final answer)?

By definition, T[U,m]T[U,m], where m:=∣F∣m := |\mathcal{F}|.

Do we have a kickstart (AKA, what are the base cases)?

Observe that T[∅,0]=0T[\emptyset, 0]=0 while T[X,0]=+∞T[X, 0]=+\infty for X≠∅X \neq \emptyset.

How do the fragments come together (AKA, how do we compute the values that we have agreed to store)?

Let X⊆UX \subseteq U and 0<j≤∣F∣0<j \leq|\mathcal{F}|. We have that:

T[X,j]=min⁡(T[X,j−1], 1+T[X\Fj,j−1]),T[X, j]=\min \left(T[X, j-1],\ 1+T\left[X \backslash F_j, j-1\right]\right),

depending on whether we decide to include FjF_j in our solution or not. If we do, we adjust the set of elements that need to be covered, and if we don't, we push the full responsibility of covering XX to the smaller subfamily. As usual, we pick the best of both worlds.

Can we put the pieces together without getting stuck (AKA, are the dependencies in step #4 acyclic)?

The entries can be computed by processing sets of smaller sizes before larger ones, and for sets of the same size, processing smaller indices before larger ones.

Analysis of Running Time

By using the recurrence, we compute all values T[X,j]T[X, j] for X⊆UX \subseteq U and 0⩽j⩽∣F∣0 \leqslant j \leqslant |\mathcal{F}|. The running time is therefore 2∣U∣(∣U∣+∣F∣)O(1)2^{|U|}(|U|+|\mathcal{F}|)^{\mathcal{O}(1)}.

Proof of Correctness

Correctness of the DP

Theorem. Given a SET COVER instance (U,F,k)(U, \mathcal{F}, k), the minimum possible size of a subfamily F′⊆F\mathcal{F}^{\prime} \subseteq \mathcal{F} that covers UU can be found in time 2∣U∣(∣U∣+∣F∣)O(1)2^{|U|}(|U|+|\mathcal{F}|)^{\mathcal{O}(1)}.

Proof. Let F={F1,F2,…,F∣F∣}\mathcal{F}=\left\{F_1, F_2, \ldots, F_{|\mathcal{F}|}\right\}. We prove the correctness of the recurrence by showing inequalities in both directions.

In one direction, let F′⊆{F1,F2,…,Fj}\mathcal{F}^{\prime} \subseteq\left\{F_1, F_2, \ldots, F_j\right\} be a family of minimum size that covers XX. We distinguish two cases. If Fj∉F′F_j \notin \mathcal{F}^{\prime}, then F′\mathcal{F}^{\prime} is also a valid candidate for the entry T[X,j−1]T[X, j-1]. If Fj∈F′F_j \in \mathcal{F}^{\prime}, then F′\{Fj}\mathcal{F}^{\prime} \backslash\left\{F_j\right\} is a valid candidate for the entry T[X\Fj,j−1]T\left[X \backslash F_j, j-1\right].

In the other direction, observe that any valid candidate F′\mathcal{F}^{\prime} for the entry T[X,j−1]T[X, j-1] is also a valid candidate for T[X,j]T[X, j] and, moreover, for every valid candidate F′\mathcal{F}^{\prime} for T[X\Fj,j−1]T\left[X \backslash F_j, j-1\right], the family F′∪{Fj}\mathcal{F}^{\prime} \cup\left\{F_j\right\} is a valid candidate for T[X,j]T[X, j].

This completes the proof.