Knuth Algorithm X: Selecting B,D & F over A

  • Thread starter woundedtiger4
  • Start date
  • Tags
    Algorithm
In summary, the algorithm tries to find a combination of rows that includes every number from 1 to 7 but where each number only occurs in at most one row. A is the row that has the most numbers in it, so it removes any sets that have a number in common with A (in this case, B,C,E and F). D is the only possible match for A, but because D doesn't contain a '2' it doesn't work and the algorithm goes to test for another combination.
  • #1
woundedtiger4
188
0
Hi all, at http://en.wikipedia.org/wiki/Knuth's_Algorithm_X in the example I don't understand that why not "A" is in the final solution & only B, D & F are in the final solution whereas "A" was selected at Level 1
 
Technology news on Phys.org
  • #2
[STRIKE]bump[/STRIKE]

plus why at the level 1 the branch containing "D" (i.e. containing 0, 1, 1, 1 in columns 2, 3, 5 & 6) was terminated unsuccessfully?
 
Last edited:
  • #3
woundedtiger4 said:
Hi all, at http://en.wikipedia.org/wiki/Knuth's_Algorithm_X in the example I don't understand that why not "A" is in the final solution & only B, D & F are in the final solution whereas "A" was selected at Level 1

woundedtiger4 said:
[STRIKE]bump[/STRIKE]

plus why at the level 1 the branch containing "D" (i.e. containing 0, 1, 1, 1 in columns 2, 3, 5 & 6) was terminated unsuccessfully?

The intent, as far as I understand it, is to find a combination of rows that include every number from 1 to 7 but where each number only occurs in at most one row.

The algorithm seems to work by picking the row (A) that has the most numbers in it and then trying to find a combination of the other rows that have the numbers that aren't in A.

Having selected A (in this case), it proceeds by removing any sets that have a number in common with A (in this case, B,C,E and F). This is because any combination of B,C,E or F with A will have at least one multiple of '1', '4' or '7'. This only leaves row D as a possible match for A.

However, row D doesn't contain a '2' and neither does A, so the combination of A and D is not an exact cover, hence the algorithm terminates and goes to test for another combination.

NR
 
  • #4
NemoReally said:
The intent, as far as I understand it, is to find a combination of rows that include every number from 1 to 7 but where each number only occurs in at most one row.

The algorithm seems to work by picking the row (A) that has the most numbers in it and then trying to find a combination of the other rows that have the numbers that aren't in A.

Having selected A (in this case), it proceeds by removing any sets that have a number in common with A (in this case, B,C,E and F). This is because any combination of B,C,E or F with A will have at least one multiple of '1', '4' or '7'. This only leaves row D as a possible match for A.

However, row D doesn't contain a '2' and neither does A, so the combination of A and D is not an exact cover, hence the algorithm terminates and goes to test for another combination.

NR

thank you sooooooooooo much, you really helped me in understanding it.
 
  • #5


Thank you for bringing up this question. Knuth's Algorithm X is a backtracking algorithm used for solving exact cover problems, where the goal is to find a subset of a given set that satisfies a set of constraints. In this particular example, the given set is a matrix with rows representing possible solutions and columns representing constraints. The goal is to find a subset of rows that satisfies all the constraints, or in other words, to find an exact cover.

In the first level of the algorithm, we select a column with the lowest number of 1s, which in this case is column A. This means that we want to include row A in our solution. However, as we move on to the next level, we encounter a conflict where row A shares a 1 with row C in column C. This means that if we were to include row A in our solution, we would not be able to include row C, and therefore not satisfy the constraint for column C.

In order to find an exact cover, we need to backtrack and try a different combination of rows. This is where the algorithm selects row B in the second level. By selecting B, we are able to satisfy the constraint for column A and also include row D in our solution. Moving on to the third level, we encounter a similar conflict with row F sharing a 1 with row E in column E. This leads us to backtrack again and try selecting row D in the fourth level, which finally allows us to include row F and satisfy all the constraints.

In summary, the reason why "A" is not in the final solution is because it creates a conflict with other rows in the matrix. Knuth's Algorithm X is designed to find an exact cover, and in this case, the combination of rows B, D, and F is the only one that satisfies all the constraints. I hope this explanation helps clarify the selection process in this example.
 

Related to Knuth Algorithm X: Selecting B,D & F over A

1. What is Knuth Algorithm X?

Knuth Algorithm X is a backtracking algorithm developed by computer scientist Donald Knuth for solving the exact cover problem, which involves finding a combination of subsets that satisfy certain constraints.

2. How does Knuth Algorithm X work?

Knuth Algorithm X works by recursively selecting and removing columns and rows from a matrix until a solution is found. It then backtracks and repeats the process until all solutions have been found.

3. What is the significance of selecting B, D, and F over A in Knuth Algorithm X?

The selection of B, D, and F over A is arbitrary and does not affect the efficiency or effectiveness of the algorithm. It is simply a way to represent the input data in a matrix form.

4. Can Knuth Algorithm X be used for other problems besides the exact cover problem?

Yes, Knuth Algorithm X can be adapted to solve other problems such as Sudoku, N-queens, and other constraint satisfaction problems.

5. Are there any limitations to using Knuth Algorithm X?

Knuth Algorithm X can only be used for problems that can be represented in a matrix form and have a unique solution. It also requires a significant amount of memory and may not be suitable for large datasets.

Similar threads

  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
1
Views
807
  • Programming and Computer Science
Replies
1
Views
878
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
11
Views
860
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
1
Views
807
  • Programming and Computer Science
Replies
29
Views
3K
Back
Top