MAS334 Combinatorics

7. Rook polynomials

In this section we will consider some matching problems, which will be represented by their chessboard diagrams. We will try to count the number of partial matchings of various sizes. We will represent partial matchings by placements of non-challenging rooks, as in Example 6.7.

Problem 7.1.

Consider the matching problem E with the following chessboard diagram:

(so E={a1,a2,b1,b2,b3,c1,c2,c3}{a,b,c}×{1,2,3}).

  • (a)

    How many ways are there of placing one rook?

  • (b)

    How many ways are there of placing two non-challenging rooks?

  • (c)

    How many ways are there of placing three non-challenging rooks?

Solution.
  • (a)

    There are 8 white squares, and thus 8 ways of placing one rook. We can list them as follows:

    a1,a2,b1,b2,b3,c1,c2,c3.
  • (b)

    By inspection, there are 14 ways of placing two non-challenging rooks. They can be listed as follows:

    a1b2,a1b3,a1c2,a1c3,a2b1,a2b3,a2c1,a2c3,b1c2,b1c3,b2c1,b2c3,b3c1,b3c2.
  • (c)

    If we place three non-challenging rooks, then there must be one in each row. There are two choices for where to place the rook in row a. Then there are again two choices for where to place the rook in row b, because it is not allowed to go directly underneath the rook in row a. We have now blocked out two of the squares in row c, leaving only one possible choice for the third rook. This gives 2×2×1=4 ways of placing three non-challenging rooks. We can list them as follows:

    a1b2c3,a1b3c2,a2b1c3,a2b3c1.

    Alternatively, we can display the chessboard diagrams:

  • (d)

    It is clearly impossible to place more than three non-challenging rooks. By convention, we also say that there is one way of placing no rooks.

Definition 7.2.

Let B{1,,n}2 be a matching problem (typically represented by an n×n chessboard diagram, with the elements of E coloured white, and the elements not in E coloured black). We write Ck(B) for the set of partial matchings ME with |M|=k. (Such a partial matching corresponds to a placement of k non-challenging rooks on B.) We write ck(B)=|Ck(B)|, so ck(B) is the number of partial matchings of size k, or the number of ways of placing k non-challenging rooks on B. We note that when k>n we have Ck(B)= and ck(B)=0, and we put

rB(t)=k=0nck(B)tk.

We call this the rook polynomial for B.

Remark 7.3.

There is only one way of placing no rooks, so c0(B)=1. The number of ways of placing one rook is just the number of white squares in B, which will write as |B|, so c1(B)=|B|. This means that

rB(x)=1+|B|x+.

The higher coefficients are harder to calculate. In Problem 7.1, we showed that c2(B)=14 and c3(B)=4 and ck(B)=0 for k>3, so

rB(x)=1+8x+14x2+4x3.
Remark 7.4.

It is clear that rotating or reflecting a board does not affect the set of non-challenging rook placements, and so does not affect the rook polynomial.

Example 7.5.

Let Ln be the full 1×n board, with all squares white:

It is clearly impossible to place more than one rook on Ln without the rooks challenging each other, so we just have rLn(x)=1+nx.

Example 7.6.

Put Dn={(1,1),(2,2),,(n,n)}, so the corresponding chessboard diagram has white squares on the diagonal and black squares everywhere else.

It is clearly impossible for two rooks placed anywhere on Dn to challenge each other. Thus, Ck(Dn) just consists of all subsets of size k in Dn, which means that ck(Dn)=(nk). This gives

rDn(x)=k=0n(nk)xk=(1+x)n.
Example 7.7.

Consider a full 3×3 board B, with all squares white:

  • (a)

    There are 9 squares, and thus 9 ways of placing one rook, so c1(B)=9. We can list them as follows:

    C1(B)={a1,a2,a3,b1,b2,b3,c1,c2,c3}.
  • (b)

    If we place two non-challenging rooks, then they must be in different rows, leaving the third row empty. There are three ways to choose the empty row. Then there are three ways place a rook in the upper non-empty row. This blocks off one of the spaces in the lower non-empty row, leaving only two choices for where to place the second rook. Altogether, this gives 3×3×2=18 ways of placing two non-challenging rooks, so c2(B)=18. We can list them as follows:

    C2(B)={ a1b2,a1b3,a1c2,a1c3,a2b1,a2b3,a2c1,a2c3,a3b1,
    a3b2,a3c1,a3c2,b1c2,b1c3,b2c1,b2c3,b3c1,b3c2}.
  • (c)

    If we place three non-challenging rooks, then there must be one in each row. There are three choices for where to place the rook in row a. Then there are only two choices for where to place the rook in row b, because it is not allowed to go directly underneath the rook in row a. We have now blocked out two of the squares in row c, leaving only one possible choice for the third rook. This gives 3×2×1=6 ways of placing three non-challenging rooks, so c3(B)=6. We can list them as follows:

    C3(B)={a1b2c3,a1b3c2,a2b1c3,a2b3c1,a3b1c2,a3b2c1}.

    Alternatively, we can display the chessboard diagrams:

We now see that

rB(x)=1+9x+18x2+6x3.
Example 7.8.

Now consider the following board B:

The possible rook placements are as follows:

  • C0(B)={} so c0(B)=1.

  • C1(B)={a3,b1,b2,c1,c2,d4} so c1(B)=6.

  • C2(B)={a3b1,a3b2,a3c1,a3c2,a3d4,b1c2,b1d4,b2c1,b2d4,c1d4,c2d4} so c2(B)=11.

  • C3(B)={a3b1c2,a3b1d4,a3b2c1,a3b2d4,a3c1d4,a3c2d4,b1c2d4,b2c1d4} so c3(B)=8.

  • C4(B)={a3b1c2d4,a3b2c1d4} so c2(B)=2.

(Later, we will discuss a systematic method to construct these lists.) From this we see that the rook polynomial is

rB(x)=1+6x+11x2+8x3+2x4.

We next generalise Example 7.7.

Definition 7.9.

We write Fmn for the full m×n board (with all squares white). Thus, as a set, we just have

Fmn={1,,m}×{1,,n}={(i,j)| 1im, 1jn}.

We also write Fn=Fnn, so Fn is the full n×n square board.

Proposition 7.10.

Consider Cn(Fn), which is the set of ways of placing n non-challenging rooks on the full n×n board. Then this set can be identified with the set of permutations of {1,,n}, so cn(Fn)=n!.

Proof.

Any element of Cn(B) is a placement of n non-challenging rooks. As the rooks do not challenge each other, we have at most one rook per row. As we have n rooks and only n rows, there must be a rook in every row. Let σ(i) be the horizontal position of the rook in row i, so σ is a function from the set N={1,,n} to itself. Similarly, each column must contain precisely one rook. Let τ(j) be the vertical position of the rook in column j. It is then easy to see that the functions σ and τ are inverse to each other, so σ is a bijection, or in other words a permutation. Conversely, if we are given a permutation σ then we can place a rook in position (i,σ(i)) for i=1,,n, and this gives us n non-challenging rooks. ∎

Proposition 7.11.

Consider the full m×n board, denoted by Fmn. Then for 0kmin(m,n) there are precisely (mk)(nk)k! ways of placing k non-challenging rooks on Fmn, so ck(Fmn)=(mk)(nk)k!. Thus, the rook polynomial is

rFmn(x)=k=0min(m,n)(mk)(nk)k!xk.

In particular, for a square board of size n×n we have

rFn(x)=k=0n(nk)2k!xk.
Example 7.12.

For the case m=n=3, the claim is that

rB(x) =(30)20!+(31)21!x+(32)22!x2+(33)3!x3
=1+9x+18x2+6x3,

which agrees with Example 7.7.

Proof.

If we have k non-challenging rooks, then they must lie in k different rows. There are (mk) ways of choosing the rows in which the rooks will appear. Similarly, the rooks must lie in k different columns. There are (nk) ways of choosing the columns in which the rooks will appear. Now suppose we have chosen the rows and columns. If we ignore all the other rows and columns, we are just left with a k×k board, on which we need to place k non-challenging rooks. There are k! ways to do this, by Proposition 7.10. Thus, we have (mk)(nk)k! possibilities altogether. ∎

Problem 7.13.

Let B be an n×n board in which the main diagonal squares are black and all other squares are white. The case n=5 is shown below.

How many ways are there of placing n non-challenging rooks on this board?

Solution.

This is a problem that we have already solved, but slightly disguised. For any permutation σ of the set N={1,,n} we have a rook placement with rooks in positions (i,σ(i)). However, we want to ensure that no rooks are on the black squares, which are in positions (i,i). Thus, we need to have σ(i)i for all i. This is precisely the condition for σ to be a derangement, as introduced in Definition 5.8. Thus, the number of ways of placing n non-challenging rooks is the same as the number of derangements, which is n!k=0n(-1)k/k!n!e-1 by Proposition 5.11.

Problem 7.14.

Suppose we have people A,B,C and D, and jobs a,b,c and d, with qualifications as follows:

  • a can be done by A or D;

  • b can be done by B or D;

  • c can be done by B or C;

  • d can be done by A or B.

Is it possible to solve the job allocation problem, and if so, in how many ways?

Solution.

The chessboard diagram for this matching problem is as follows:

The job allocation problem is equivalent to the problem of placing four non-challenging rooks on this board. This means that we must have a rook in each row. The rook in row C must be at Cc, and this means that the rook in row B cannot be at Bc, so it must be at Bb or Bd.

  • Suppose we place a rook at Aa. This blocks Da, so the rook in row D must be at Db. Now Bb and Bc are blocked by Db and Cc, so the rook in row B must be at Bd. This gives a full matching AaBdCcDb.

  • Suppose instead that we place a rook at Ad. This blocks Bd, and Bc is also blocked by Cc, so the rook in row B must be at Bb. Now Db is blocked by Bb, so the rook in row D must be at Da. This gives a full matching AdBbCcDa.

From this we see that there are precisely two full matchings. Equivalently, there are precisely two ways to allocate the jobs subject to the usual rules: each person should have precisely one job, and each job should be done by precisely one person.

We will next give two examples where we can show that an interesting problem is equivalent to a rook placement problem. However, we will not yet solve the resulting rook placement problems. Instead, we will first develop some general techniques, which will make the task easier.

Problem 7.15.

One version of the game of Snap works as follows. There are two players, each of whom has a full pack of 52 cards. At each turn, both players take a card from the top of their pack. If the two cards have the same value (for example, they are both kings or both sevens) then that counts as a snap, and the game ends. Of course, it could happen that the game continues for 52 turns and the players play all of their cards but still no snap has happened. What is the probability of this?

Solution.

For simplicity, we will first consider the case where the decks just have the aces, kings, queens and jacks, so there are only 16 cards altogether. We will number the cards as 1,,16, with cards 1-4 being the aces, cards 5-8 being the kings, 9-12 being the queens and 13-16 the jacks. We will analyse the problem using the following board:

Squares are coloured black if the corresponding row and column markers have the same value; they are coloured white if the row and column markers have different values. For example, the (K♣,K♥) square is black (because the two markers are both kings) but the (Q♥,J♠) square is white.

We will assume for simplicity that the first player’s pack is unshuffled, so cards 1 to 16 appear in order, but that the second player’s pack is shuffled randomly. (We leave it as an exercise to understand why this simplifying assumption does not really change anything.) Let σ(i) be the card in position i in the second player’s pack, so σ is a random permutation, and cards i and σ(i) get played at the same time. This permutation can be represented in the usual way by placing 16 rooks on the board, with the i’th rook at position (i,σ(i)). Suppose, for example, that σ(6)=3, so cards 6 and 3 get played together. Card 6 is K♥, and card 3 is A♠. These have different values, so this is not a snap. This corresponds to the fact that the square (6,3) is white. Suppose, for another example, that σ(9)=11, so cards 9 and 11 are played together. Card 9 is Q♣ and card 11 is Q♠, so this is a snap. This corresponds to the fact that the square (9,11) is black. Thus, our game has a snap if there is a rook on a black square, but there is no snap if all the rooks are on white squares. Thus, our main task is to calculate the number of ways of placing 16 non-challenging rooks using the white squares only. We will return to this calculation when we have developed a bit more theory.

Problem 7.16.

Suppose we have a dinner party with ten guests, who are to be seated at a round table. There are five married couples, each consisting of a man and a woman. We want to arrange the seating so that the men alternate with the women, and no one sits next to their spouse. How many ways are there to do this? (This is sometimes called the ménage problem.)

Solution.

We label the seats as follows:

The first choice to make is whether the women get the seats with letters or the seats with numbers; this will give an overall factor of two. For the rest of the analysis, we will assume that the women get the letters. Next, there are 5!=120 ways to assign the 5 women to seats A,,E. Now suppose we have seated the women, and we want to seat the men. We will refer to the woman in seat A as woman A, and to her husband as man A, and so on. Now man A is not supposed to sit next to his wife, so he can sit in seats 2, 3 or 4 but not 1 or 5. Similarly, man B can sit in seats 3, 4 or 5, and man C can sit in seats 4, 5 or 1, and so on. These rules can be represented by the following chessboard diagram:

Our seating problem is equivalent to the problem of finding a full matching for this board. (A rook in position B4 corresponds to putting man B in seat 4, for example.) We will show later that there are 13 such matchings. This means that there are 2×120×13=3120 possible solutions to the original problem.