ArticleslgStudy

computer science

Set cover problem

Set cover problem is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Set cover problem rather than just read about it. In short: The set cover problem is a classical question in combinatorics, computer science, operations research, and complexity theory. Given a set of elements {1, 2, …, n} (henceforth referred to as the universe, specifying all possible elements under consideration) and a collection, referred to as S, of a given m subsets whose union equals the universe, the set cover problem is to identify a smallest sub-collection of S who…

Set cover problem — main illustration
Set cover problem — illustration

Key takeaways

  • Set cover problem belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Set cover problem to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Set cover problem from memory before moving on to harder problems.

Reference excerpt

The set cover problem is a classical question in combinatorics, computer science, operations research, and complexity theory. Given a set of elements {1, 2, …, n} (henceforth referred to as the universe, specifying all possible elements under consideration) and a collection, referred to as S, of a given m subsets whose union equals the universe, the set cover problem is to identify a smallest sub-collection of S whose union equals the universe. For example, consider the universe, U = {1, 2, 3, 4, 5} and the collection of sets S = { {1, 2, 3}, {2, 4}, {3, 4}, {4, 5} }. In this example, m is equal to 4, as there are four subsets that comprise this collection. The union of S is equal to U. However, we can cover all elements with only two sets: { {1, 2, 3}, {4, 5} }‍, but not with only one set. Therefore, the solution to the set cover problem for this U and S has size 2. This example is illustrated in the picture above. More formally, given a universe 𝒰 and a family 𝒮 of subsets of 𝒰, a set cover is a subfamily 𝒞⊆𝒮 of sets whose union is 𝒰.

In the set cover decision problem, the input is a pair (𝒰,𝒮) and an integer k; the question is whether there is a set cover of size k or less. In the set cover optimization problem, the input is a pair (𝒰,𝒮), and the task is to find a set cover that uses the fewest sets. The decision version of set covering is NP-complete. It is one of Karp's 21 NP-complete problems shown to be NP-complete in 1972. The optimization/search version of set cover is NP-hard. It is a problem "whose study has led to the development of fundamental techniques for the entire field" of approximation algorithms.

Variants In the weighted set cover problem, each set is assigned a positive weight (representing its cost), and the goal is to find a set cover with a smallest weight. The usual (unweighted) set cover corresponds to all sets having a weight of 1.

In the fractional set cover problem, it is allowed to select fractions of sets, rather than entire sets. A fractional set cover is an assignment of a fraction (a number in [0,1]) to each set in 𝒮, such that for each element x in the universe, the sum of fractions of sets that contain x is at least 1. The goal is to find a fractional set cover in which the sum of fractions is as small as possible. Note that a (usual) set cover is equivalent to a fractional set cover in which all fractions are either 0 or 1; therefore, the size of the smallest fractional cover is at most the size of the smallest cover, but may be smaller. For example, consider the universe U = {1, 2, 3} and the collection of sets S = { {1, 2}, {2, 3}, {3, 1} }. The smallest set cover has a size of 2, e.g. { {1, 2}, {2, 3} }. But there is a fractional set cover of size 1.5, in which a 0.5 fraction of each set is taken. In the capacitated set cover problem, each set s∈𝒮 is associated with a capacity cS which denotes the number of elements it can supply coverage. The goal is to determine the optimal way to select sets such that each element receives the coverage it requires.

Linear program formulation The set cover problem can be formulated as the following integer linear program (ILP).

For a more compact representation of the covering constraint, one can define an incidence matrix A, where each row corresponds to an element and each column corresponds to a set, and Ae,s=1 if element e is in set s, and Ae,s=0 otherwise. Then, the covering constraint can be written as Ax⩾1. Weighted set cover is described by a program identical to the one given above, except that the objective function to minimize is ∑s∈𝒮wsxs, where ws is the weight of set s∈𝒮. Fractional set cover is described by a program identical to the one given above, except that xs can be non-integer, so the last constraint is replaced by 0≤xs≤1. This linear program belongs to the more general class of LPs for covering problems, as all the coefficients in the objective function and both sides of the constraints are non-negative. The integrality gap of the ILP is at most log⁡n (where n is the size of the universe). It has been shown that its relaxation indeed gives a factor-log⁡n approximation algorithm for the minimum set cover problem. See setcover for a detailed explanation.

Hitting set formulation The set cover problem is equivalent to the hitting set problem. A subset H of U is called a hitting set when H∩Sj≠∅︀ for all 1≤j≤m (i.e., H intersects or "hits" all subsets in S). The hitting set problem is to find a minimum hitting set H for a given U and S. To show that the problems are equivalent, for a universe U of size n and collection of sets S of size m, construct U′={1,2,…,m} and S'i={j∣i∈Sj}. Then a set cover C of S is equivalent to a hitting set H′ of U′ where Sj∈C⟺j∈H′, and vice versa. This equivalence can also be visualized by representing the problem as a bipartite graph of n+m vertices, with n vertices on the left representing elements of U, and m vertices on the right representing elements of S, and edges representing set membership (i.e., there is an edge between the i-th vertex on the left and the j-th vertex of the right iff. i∈Sj). Then a set cover is a subset C of right vertices such that each left vertex is adjacent to at least one member of C, while a hitting set is a subset H of left vertices such that each right vertex is adjacent to at least one member of H. These definitions are exactly the same except that left and right are swapped. But there is nothing special about the sides in the bipartite graph; we could have put the elements of U on the right side, and the elements of S on the left side, creating a graph that is a mirror image of the one described above. This shows that set covers in the original graph are equivalent to hitting sets in the mirrored graph, and vice versa. In the field of computational geometry, a hitting set for a collection of geometrical objects is also called a stabbing set or piercing set.

Greedy algorithm There is a greedy algorithm for polynomial time approximation of set covering that chooses sets according to one rule: at each stage, choose the set that contains the largest number of uncovered elements. This method can be implemented in time linear in the sum of sizes of the input sets, using a bucket queue to prioritize the sets. It achieves an approximation ratio of H(s), where s is the size of the set to be covered.

… excerpt ends here. Continue reading the full article.

Illustrations

Set cover problem: Example of an instance of set cover problem.
Example of an instance of set cover problem.
Set cover problem: Tight example for the greedy algorithm with k=3
Tight example for the greedy algorithm with k=3

Worked examples

Example 1 — a first encounter with Set cover problem

Start with the simplest possible case. Write down what Set cover problem claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Set cover problem before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Set cover problem ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Set cover problem

In research
Set cover problem appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Set cover problem in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Set cover problem is common in secondary-school and first-year university syllabi. It links to neighbouring topics Approximation algorithms, Covering problems, Families of sets, so understanding it makes those chapters shorter.
In everyday life
Look for Set cover problem outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Set cover problem” →

How to study Set cover problem in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Set cover problem means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Set cover problem out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Set cover problem in simple terms?

The set cover problem is a classical question in combinatorics, computer science, operations research, and complexity theory. Given a set of elements {1, 2, …, n} (henceforth referred to as the universe, specifying all possible elements under consideration) and a collection, referred to as S, of a…

Why does Set cover problem matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Set cover problem?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Set cover problem.

Tags

  • Approximation algorithms
  • Covering problems
  • Families of sets
  • Linear programming
  • NP-complete problems

Keep exploring