VOOZH about

URL: https://www.geeksforgeeks.org/dsa/introduction-to-exact-cover-problem-and-algorithm-x/

⇱ Introduction to Exact Cover Problem and Algorithm X - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Introduction to Exact Cover Problem and Algorithm X

Last Updated : 19 Mar, 2026

If you have ever tried to create a program for solving Sudoku, you might have come across the Exact Cover problem. We will discuss what is the exact cover problem and an algorithm “Algorithm X” proposed by Donald Knuth to solve this problem. Given a collection S of subsets of set X, an exact cover is the subset S* of S such that each element of X is contained is exactly one subset of S*.

It should satisfy following two conditions -

  • The Intersection of any two subsets in S* should be empty. That is, each element of X should be contained in at most one subset of S*
  • Union of all subsets in S* is X. That means union should contain all the elements in set X. So we can say that S* covers X.

Example (standard representation) - Let S = { A, B, C, D, E, F } and 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}
  • F = {2, 7}

Then S* = {B, D, F} is an exact cover, because each element in X is contained exactly once in subsets {B, D, F} . If we union subsets then we will get all the elements of X -

Comment
Article Tags:
Article Tags: