ArticleslgStudy

computer science

Exact cover

Exact cover 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 Exact cover rather than just read about it. In short: In the mathematical field of combinatorics, given a collection 𝒮 of subsets of a set X, an exact cover is a subcollection 𝒮∗ of 𝒮 such that each element in X is contained in exactly one subset in 𝒮∗. One says that each element in X is covered by exactly one subset in 𝒮∗.

Exact cover — main illustration
Exact cover — illustration

Key takeaways

  • Exact cover 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 Exact cover to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Exact cover from memory before moving on to harder problems.

Reference excerpt

In the mathematical field of combinatorics, given a collection 𝒮 of subsets of a set X, an exact cover is a subcollection 𝒮∗ of 𝒮 such that each element in X is contained in exactly one subset in 𝒮∗. One says that each element in X is covered by exactly one subset in 𝒮∗. An exact cover is a kind of cover. In other words, 𝒮∗ is a partition of X consisting of subsets contained in 𝒮. The exact cover problem to find an exact cover is a kind of constraint satisfaction problem. The elements of 𝒮 represent choices and the elements of X represent constraints. It is NP-hard and has a variety of applications, ranging from the optimization of airline flight schedules, cloud computing, and electronic circuit design. An exact cover problem involves the relation contains between subsets and elements. But an exact cover problem can be represented by any heterogeneous relation between a set of choices and a set of constraints. For example, an exact cover problem is equivalent to an exact hitting set problem, an incidence matrix, or a bipartite graph. In computer science, the exact cover problem is a decision problem to determine if an exact cover exists. The exact cover problem is NP-complete and is one of Karp's 21 NP-complete problems. It is NP-complete even when each subset in S contains exactly three elements; this restricted problem is known as exact cover by 3-sets, often abbreviated X3C. Knuth's Algorithm X is an algorithm that finds all solutions to an exact cover problem. DLX is the name given to Algorithm X when it is implemented efficiently using Donald Knuth's Dancing Links technique on a computer. The exact cover problem can be generalized slightly to involve not only exactly-once constraints but also at-most-once constraints. Finding Pentomino tilings and solving Sudoku are noteworthy examples of exact cover problems. The n queens problem is a generalized exact cover problem.

Formal definition Given a collection 𝒮 of subsets of a set X, an exact cover of X is a subcollection 𝒮∗ of 𝒮 that satisfies two conditions:

The intersection of any two distinct subsets in 𝒮∗ is empty, i.e., the subsets in 𝒮∗ are pairwise disjoint. In other words, each element in X is contained in at most one subset in 𝒮∗. The union of the subsets in 𝒮∗ is X, i.e., the subsets in 𝒮∗ cover X. In other words, each element in X is contained in at least one subset in 𝒮∗. In short, an exact cover is exact in the sense that each element in X is contained in exactly one subset in 𝒮∗. Equivalently, an exact cover of X is a subcollection 𝒮∗ of 𝒮 that partitions X. For an exact cover of X to exist, it is necessary that:

The union of the subsets in 𝒮 is X. In other words, each element in X is contained in at least one subset in 𝒮. If the empty set ∅︀ is contained in 𝒮, then it makes no difference whether or not it is in any exact cover. Thus it is typical to assume that:

The empty set is not in 𝒮∗. In other words, each subset in 𝒮∗ contains at least one element.

Basic examples Let 𝒮={N,O,P,E} be a collection of subsets of a set X={1,2,3,4} such that:

N={}, O={1,3}, P={1,2,3}, and E={2,4}. The subcollection {O,E} is an exact cover of X, since the subsets O={1,3} and E={2,4} are disjoint and their union is X={1,2,3,4}. The subcollection {N,O,E} is also an exact cover of X. Including the empty set N={} makes no difference, as it is disjoint with all subsets and does not change the union. The subcollection {E,P} is not an exact cover of X. Even though the union of the subsets E and P is {1,2,3,4}=X, the intersection of the subsets E and P, {2}, is not empty. Therefore the subsets E and P do not meet the disjoint requirement of an exact cover. The subcollection {N,P} is also not an exact cover of X. Even though N and P are disjoint, their union is not X, so they fail the cover requirement. On the other hand, there is no exact cover—indeed, not even a cover—of Y={1,2,3,4,5} because ⋃𝒮={1,2,3,4} is a proper subset of Y: None of the subsets in 𝒮 contains the element 5.

Detailed example

Let S = {A, B, C, D, E, F} be a collection of subsets of a set X = {1, 2, 3, 4, 5, 6, 7} such that:

A = {1, 4, 7}; B = {1, 4}; C = {4, 5, 7}; D = {3, 5, 6}; E = {2, 3, 6, 7}; and F = {2, 7}. The subcollection S* = {B, D, F} is an exact cover, since each element is covered by (contained in) exactly one selected subset, as the highlighting makes clear. Moreover, {B, D, F} is the only exact cover, as the following argument demonstrates: Because A and B are the only subsets containing the element 1, an exact cover must contain A or B, but not both. If an exact cover contains A, then it doesn't contain B, C, E, or F, as each of these subsets has the element 1, 4, or 7 in common with A. Then D is the only remaining subset, but the subcollection {A, D} doesn't cover the element 2. In conclusion, there is no exact cover containing A. On the other hand, if an exact cover contains B, then it doesn't contain A or C, as each of these subsets has the element 1 or 4 in common with B. Because D is the only remaining subset containing the element 5, D must be part of the exact cover. If an exact cover contains D, then it doesn't contain E, as E has the elements 3 and 6 in common with D. Then F is the only remaining subset, and the subcollection {B, D, F} is indeed an exact cover. See the example in the article on Knuth's Algorithm X for a matrix-based version of this argument.

Representations An exact cover problem is defined by the heterogeneous relation contains between a collection S of subsets and a set X of elements. But there is nothing fundamental about subsets and elements. A representation of an exact cover problem arises whenever there is a heterogeneous relation R ⊆ S × X between a set S of choices and a set X of constraints and the goal is to select a subset S* of S such that each element in X is RT-related to exactly one element in S*. Here RT is the converse of R. In general, RT restricted to X × S* is a function from X to S*, which maps each element in X to the unique element in S* that is R-related to that element in X. This function is onto, unless S* contains an element (akin to the empty set) that isn't R-related to any element in X. Representations of an exact cover problem include an exact hitting set problem, an incidence matrix, and a bipartite graph.

… excerpt ends here. Continue reading the full article.

Illustrations

Exact cover illustration
Exact cover illustration

Worked examples

Example 1 — a first encounter with Exact cover

Start with the simplest possible case. Write down what Exact cover 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 Exact cover 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 Exact cover 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 Exact cover

In research
Exact cover 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 Exact cover 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
Exact cover is common in secondary-school and first-year university syllabi. It links to neighbouring topics NP-complete problems, Theoretical computer science, so understanding it makes those chapters shorter.
In everyday life
Look for Exact cover 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 “Exact cover” →

How to study Exact cover in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Exact cover 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 Exact cover out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Exact cover in simple terms?

In the mathematical field of combinatorics, given a collection 𝒮 of subsets of a set X, an exact cover is a subcollection 𝒮∗ of 𝒮 such that each element in X is contained in exactly one subset in 𝒮∗. One says that each element in X is covered by exactly one subset in 𝒮∗.

Why does Exact cover 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 Exact cover?

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 Exact cover.

Tags

  • NP-complete problems
  • Theoretical computer science

Keep exploring