Neeldhara
  • About
  • Research
    • Overview
    • People
    • Publications
    • Surveys
  • Teaching
    • Courses
    • Materials
  • Lists
    • Puzzles
    • Bookmarks
  • Exposition
    • Talks
    • Videos
  • Events
  • Blog

3. Set Cover

  • Advanced Algorithms
    • Flows
    • Intractability
    • Approximation Algorithms
    • Randomized Algorithms
    • Greedy Algorithms
      • 1. Storing Files on a Tape
      • 2. A Scheduling Problem
      • 3. Stable Matchings
    • Matroids
      • 1. The Motivation
      • 2. The Definition
      • 3. Greedy Works!
      • 4. Scheduling with Deadlines
    • Dynamic Programming
      • 1. Longest Increasing Subsequence
      • 2. Subset Sum
      • 3. Set Cover
      • 4. Optimal BSTs
      • 5. Maximum Independent Set on Trees

On this page

  • The Problem
  • The Solution
  • Analysis of Running Time
  • Proof of Correctness

3. Set Cover

algonotes
lecturenotes
Published

May 16, 2023

Acknowledgements

Much of the material in this section is borrowed from Chapter 6 in Parameterized Algorithms.

The Problem

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

The Set Cover problem is the following:

  • The input is a family of sets F\mathcal{F}F over a universe UUU and a positive integer kkk.
  • The task is to check whether there exists a subfamily F′⊆F\mathcal{F}^{\prime} \subseteq \mathcal{F}F′⊆F of size at most kkk such that F′\mathcal{F}^{\prime}F′ covers UUU.

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

The Solution

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

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

Define T[X,j]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\}F′⊆{F1​,F2​,…,Fj​} that covers XXX.

The TTT’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]T[U,m], where m:=∣F∣m := |\mathcal{F}|m:=∣F∣.

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

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

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

Let X⊆UX \subseteq UX⊆U and 0<j≤∣F∣0<j \leq|\mathcal{F}|0<j≤∣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), T[X,j]=min(T[X,j−1],1+T[X\Fj​,j−1]),

depending on whether we decide to include FjF_jFj​ in our solution or not. If we do, then we adjust the set of elements that need to be covered, and if we don’t, we push the full responsibility of covering XXX 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 computing 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]T[X,j] for X⊆UX \subseteq UX⊆U and 0⩽j⩽∣F∣0 \leqslant j \leqslant |\mathcal{F}|0⩽j⩽∣F∣. The running time is therefore 2∣U∣(∣U∣+∣F∣)O(1)2^{|U|}(|U|+|\mathcal{F}|)^{\mathcal{O}(1)}2∣U∣(∣U∣+∣F∣)O(1).

Proof of Correctness

Correctness of the DP

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

Proof. Let F={F1,F2,…,F∣F∣}\mathcal{F}=\left\{F_1, F_2, \ldots, F_{|\mathcal{F}|}\right\}F={F1​,F2​,…,F∣F∣​}. 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\{\overline{F_1}, F_2, \ldots, F_j\right\}F′⊆{F1​​,F2​,…,Fj​} be a family of minimum size that covers XXX. We distinguish two cases. If Fj∉F′F_j \notin \mathcal{F}^{\prime}Fj​∈/F′, then note that F′\mathcal{F}^{\prime}F′ is also a valid candidate for the entry T[X,j−1]T[X, j-1]T[X,j−1] (i.e., F′⊆{F1,F2,…,Fj−1}\mathcal{F}^{\prime} \subseteq\left\{F_1, F_2, \ldots, F_{j-1}\right\}F′⊆{F1​,F2​,…,Fj−1​} and F′\mathcal{F}^{\prime}F′ covers XXX ). If Fj∈F′F_j \in \mathcal{F}^{\prime}Fj​∈F′, then F′\{Fj}\mathcal{F}^{\prime} \backslash\left\{F_j\right\}F′\{Fj​} is a valid candidate for the entry T[X\Fj,j−1]T\left[X \backslash F_j, j-1\right]T[X\Fj​,j−1].

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

This completes the proof.


© 2022 • Neeldhara Misra • Credits •

 

Corrections? Please leave a comment here or a PR in this repository, thanks!

I’d rather be a failure at something I love than a success at something I hate.

George Burns

You live and you learn — at any rate, you live.

Douglas Adams

A problem worthy of attack proves its worth by fighting back.

Paul Erdos

×