3. Set Cover
Acknowledgements
Some of this material is borrowed from Jeff Erickson's chapters on Recursion, Backtracking, and Dynamic Programming.
The Problem
Let be a family of sets over a universe . For a subfamily and a subset , we say that covers if every element of belongs to some set of .
The Set Cover problem is the following:
-
The input is a family of sets over a universe and a positive integer .
-
The task is to check whether there exists a subfamily of size at most such that covers .
We describe here an algorithm for Set Cover that runs in time . In fact, this algorithm does not use the value of , and finds the minimum possible cardinality of a family that covers .
The Solution
What are the fragments (AKA, what do we want to store)?
Let us try projection again. Fix a subset and an integer .
Define as the minimum possible size of a subset that covers .
The 's will be our fragments.
Are the fragments going to be useful (AKA, where is the final answer)?
By definition, , where .
Do we have a kickstart (AKA, what are the base cases)?
Observe that while for .
How do the fragments come together (AKA, how do we compute the values that we have agreed to store)?
Let and . We have that:
depending on whether we decide to include 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 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 for and . The running time is therefore .
Proof of Correctness
Correctness of the DP
Theorem. Given a SET COVER instance , the minimum possible size of a subfamily that covers can be found in time .
Proof. Let . We prove the correctness of the recurrence by showing inequalities in both directions.
In one direction, let be a family of minimum size that covers . We distinguish two cases. If , then is also a valid candidate for the entry . If , then is a valid candidate for the entry .
In the other direction, observe that any valid candidate for the entry is also a valid candidate for and, moreover, for every valid candidate for , the family is a valid candidate for .
This completes the proof.