Marriage Problem

M

The applet below is a simulation of the W. McWorter's algorithm. The following controls are available:

  1. You can manually swap rows, columns, or both. There are three radio buttons: r, c, and b to indicate the action of your choice. Click outside the board near the row/column you want to be swapped. Then, in the same manner, pick another row/column.
  2. You can instruct the applet to perform the next step of the algorithm by pressing Step.
  3. It will continue until finished if you press either Fast or Slow.
  4. Reset can be pressed at any time.
  5. The same is true of Log. Have it on if you want a logout of the steps.
  6. When you press reset the board is filled randomly. You may click on squares to toggle their value.
  7. You may take your steps back. Note, however, that some algorithmic steps do two swaps, some do only one. You may only take back one swap at a time.

If you are reading this, your browser is not set to run Java applets. Try IE11 or Safari and declare the site https:///www.cut-the-knot.org as trusted in the Java setup.

marriage applet, W. McWorter's algorithm


What if applet does not run?

Experimenting with the applet leads to several observations:

  1. Consider a matrix with 1s in squares next to the diagonal and 0s everywhere else, aij = 1 iff |i - j| = 1, and aij = 0, otherwise. Prove that if n, the size of the matrix, is even, the complete match possible. The complete match is impossible if n is odd.

  2. Start with the unit (diagonal) matrix: aij = 1 iff i = j. This matrix has the property that there is just a single 1 in every column and every row. General matrices with this property are called permutation matrices. Such matrices appear in the Calendar Magic puzzle and the Rook Problem. The name permutation matrices is explained by the fact that such matrices supply an additional way to represent a permutation. Every permutation matrix encodes a solution to the marriage problem. The algorithm is blind to this fact. It attempts to construct a transversal of 1s, and results in the longest sequence of 1s that may be placed on the diagonal. Prove that, for a permutation matrix, the algorithm performs this task within the Greedy Phase.

Latin Squares

|Contact| |Front page| |Contents| |Algebra| |Eye opener|

Copyright © 1996-2018 Alexander Bogomolny

 63699444

Search by google: