0 - Introduction To Combinatorics
0 - Introduction To Combinatorics
COMBINATORICS
SECOND EDITION
DISCRETE
MATHEMATICS
ITS APPLICATIONS
R. B. J. T. Allenby and Alan Slomson, How to Count: An Introduction to Combinatorics,
Third Edition
Craig P. Bauer, Secret History: The Story of Cryptology
Jürgen Bierbrauer, Introduction to Coding Theory, Second Edition
Katalin Bimbó, Combinatory Logic: Pure, Applied and Typed
Katalin Bimbó, Proof Theory: Sequent Calculi and Related Formalisms
Donald Bindner and Martin Erickson, A Student’s Guide to the Study, Practice, and Tools of
Modern Mathematics
Francine Blanchet-Sadri, Algorithmic Combinatorics on Partial Words
Miklós Bóna, Combinatorics of Permutations, Second Edition
Miklós Bóna, Handbook of Enumerative Combinatorics
Miklós Bóna, Introduction to Enumerative and Analytic Combinatorics, Second Edition
Jason I. Brown, Discrete Structures and Their Interactions
Richard A. Brualdi and Dragos̆ Cvetković, A Combinatorial Approach to Matrix Theory and Its
Applications
Kun-Mao Chao and Bang Ye Wu, Spanning Trees and Optimization Problems
Charalambos A. Charalambides, Enumerative Combinatorics
Gary Chartrand and Ping Zhang, Chromatic Graph Theory
Henri Cohen, Gerhard Frey, et al., Handbook of Elliptic and Hyperelliptic Curve Cryptography
Charles J. Colbourn and Jeffrey H. Dinitz, Handbook of Combinatorial Designs, Second Edition
Abhijit Das, Computational Number Theory
Matthias Dehmer and Frank Emmert-Streib, Quantitative Graph Theory:
Mathematical Foundations and Applications
Martin Erickson, Pearls of Discrete Mathematics
Martin Erickson and Anthony Vazzana, Introduction to Number Theory
Titles (continued)
Steven Furino, Ying Miao, and Jianxing Yin, Frames and Resolvable Designs: Uses,
Constructions, and Existence
Mark S. Gockenbach, Finite-Dimensional Linear Algebra
Randy Goldberg and Lance Riek, A Practical Handbook of Speech Coders
Jacob E. Goodman and Joseph O’Rourke, Handbook of Discrete and Computational Geometry,
Second Edition
Jonathan L. Gross, Combinatorial Methods with Computer Applications
Jonathan L. Gross and Jay Yellen, Graph Theory and Its Applications, Second Edition
Jonathan L. Gross, Jay Yellen, and Ping Zhang Handbook of Graph Theory, Second Edition
David S. Gunderson, Handbook of Mathematical Induction: Theory and Applications
Richard Hammack, Wilfried Imrich, and Sandi Klavžar, Handbook of Product Graphs,
Second Edition
Darrel R. Hankerson, Greg A. Harris, and Peter D. Johnson, Introduction to Information Theory
and Data Compression, Second Edition
Darel W. Hardy, Fred Richman, and Carol L. Walker, Applied Algebra: Codes, Ciphers, and
Discrete Algorithms, Second Edition
Daryl D. Harms, Miroslav Kraetzl, Charles J. Colbourn, and John S. Devitt, Network Reliability:
Experiments with a Symbolic Algebra Environment
Silvia Heubach and Toufik Mansour, Combinatorics of Compositions and Words
Leslie Hogben, Handbook of Linear Algebra, Second Edition
Derek F. Holt with Bettina Eick and Eamonn A. O’Brien, Handbook of Computational Group Theory
David M. Jackson and Terry I. Visentin, An Atlas of Smaller Maps in Orientable and
Nonorientable Surfaces
Richard E. Klima, Neil P. Sigmon, and Ernest L. Stitzinger, Applications of Abstract Algebra
with Maple™ and MATLAB®, Second Edition
Richard E. Klima and Neil P. Sigmon, Cryptology: Classical and Modern with Maplets
Patrick Knupp and Kambiz Salari, Verification of Computer Codes in Computational Science
and Engineering
William L. Kocay and Donald L. Kreher, Graphs, Algorithms, and Optimization, Second Edition
Donald L. Kreher and Douglas R. Stinson, Combinatorial Algorithms: Generation Enumeration
and Search
Hang T. Lau, A Java Library of Graph Algorithms and Optimization
C. C. Lindner and C. A. Rodger, Design Theory, Second Edition
San Ling, Huaxiong Wang, and Chaoping Xing, Algebraic Curves in Cryptography
Nicholas A. Loehr, Bijective Combinatorics
Toufik Mansour, Combinatorics of Set Partitions
Titles (continued)
Toufik Mansour and Matthias Schork, Commutation Relations, Normal Ordering, and Stirling
Numbers
Alasdair McAndrew, Introduction to Cryptography with Open-Source Software
Elliott Mendelson, Introduction to Mathematical Logic, Fifth Edition
Alfred J. Menezes, Paul C. van Oorschot, and Scott A. Vanstone, Handbook of Applied
Cryptography
Stig F. Mjølsnes, A Multidisciplinary Introduction to Information Security
Jason J. Molitierno, Applications of Combinatorial Matrix Theory to Laplacian Matrices of Graphs
Richard A. Mollin, Advanced Number Theory with Applications
Richard A. Mollin, Algebraic Number Theory, Second Edition
Richard A. Mollin, Codes: The Guide to Secrecy from Ancient to Modern Times
Richard A. Mollin, Fundamental Number Theory with Applications, Second Edition
Richard A. Mollin, An Introduction to Cryptography, Second Edition
Richard A. Mollin, Quadratics
Richard A. Mollin, RSA and Public-Key Cryptography
Carlos J. Moreno and Samuel S. Wagstaff, Jr., Sums of Squares of Integers
Gary L. Mullen and Daniel Panario, Handbook of Finite Fields
Goutam Paul and Subhamoy Maitra, RC4 Stream Cipher and Its Variants
Dingyi Pei, Authentication Codes and Combinatorial Designs
Kenneth H. Rosen, Handbook of Discrete and Combinatorial Mathematics
Yongtang Shi, Matthias Dehmer, Xueliang Li, and Ivan Gutman, Graph Polynomials
Douglas R. Shier and K.T. Wallenius, Applied Mathematical Modeling: A Multidisciplinary
Approach
Alexander Stanoyevitch, Introduction to Cryptography with Mathematical Foundations and
Computer Implementations
Jörn Steuding, Diophantine Analysis
Douglas R. Stinson, Cryptography: Theory and Practice, Third Edition
Roberto Tamassia, Handbook of Graph Drawing and Visualization
Roberto Togneri and Christopher J. deSilva, Fundamentals of Information Theory and Coding
Design
W. D. Wallis, Introduction to Combinatorial Designs, Second Edition
W. D. Wallis and J. C. George, Introduction to Combinatorics, Second Edition
Jiacun Wang, Handbook of Finite State Based Models and Applications
Lawrence C. Washington, Elliptic Curves: Number Theory and Cryptography, Second Edition
DISCRETE MATHEMATICS AND ITS APPLICATIONS
INTRODUCTION TO
COMBINATORICS
SECOND EDITION
Walter D. Wallis
southern illinois university
CarbonDale, usa
John C. GeorGe
GorDon ColleGe, barnesville
GeorGia, usa
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable
efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication
and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc.
(CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization
that provides licenses and registration for a variety of users. For organizations that have been granted
a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and
are used only for identification and explanation without intent to infringe.
List of Figures xv
Preface xvii
1 Introduction 1
1.1 Some Combinatorial Examples . . . . . . . . . . . . . . . . . 1
1.2 Sets, Relations, and Proof Techniques . . . . . . . . . . . . . 13
1.3 Two Principles of Enumeration . . . . . . . . . . . . . . . . . 15
1.4 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5 Systems of Distinct Representatives . . . . . . . . . . . . . . 20
Exercises 1A . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Exercises 1B . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2 Fundamentals of Enumeration 27
2.1 Permutations and Combinations . . . . . . . . . . . . . . . . 27
n
2.2 Applications of P (n, k) and . . . . . . . . . . . . . . . . 29
k
2.3 Permutations and Combinations of Multisets . . . . . . . . . 32
2.4 Applications and Subtle Errors . . . . . . . . . . . . . . . . . 36
2.5 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Exercises 2A . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Exercises 2B . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3 Probability 45
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2 Some Definitions and Easy Examples . . . . . . . . . . . . . 45
3.3 Events and Probabilities . . . . . . . . . . . . . . . . . . . . 48
3.4 Three Interesting Examples . . . . . . . . . . . . . . . . . . . 52
3.5 Probability Models . . . . . . . . . . . . . . . . . . . . . . . 54
3.6 Bernoulli Trials . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.7 The Probabilities in Poker . . . . . . . . . . . . . . . . . . . 56
3.8 The Wild Card Poker Paradox . . . . . . . . . . . . . . . . . 57
Exercises 3A . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Exercises 3B . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
ix
x Contents
References 407
Index 417
List of Figures
xv
xvi List of Figures
xvii
xviii Preface
Acknowledgments
This book has benefited significantly from the comments of Ken Rosen,
and those of anonymous reviewers. We would also like to thank Robert Ross,
Preface xix
David Grubbs, and Bob Stern of Taylor & Francis Group for their assistance.
Every edition of any textbook will, unavoidably, contain errors. Each of
us wishes to state categorically that all such errors are the fault of the other
author.
Chapter 1
Introduction
Passwords
We start with an enumerative problem. Enumeration (the theory of count-
ing) is an important part of combinatorics.
Most computer systems require passwords, in order to protect your informa-
tion and your privacy. For example, the social networking program YoufaceTM
requires everybody to have an eight-character password made up of letters and
digits. The passwords are case-sensitive, but the letter O is not allowed (to
avoid confusion with zero), so there are 60 symbols available. How many
different passwords could you choose?
1
2 Introduction to Combinatorics
There are 60 choices for the first character. For each of those there are
60 possible second characters, for 3600 possible 2-character starts, and so on.
In all, there are 608 , or about 168 trillion, passwords. This calculation is an
example of the multiplication principle, which we’ll discuss further in Section
1.3, later in this chapter.
Suppose a hacker wants to break into your Youface account. She has a
program that can generate and test a thousand passwords per second. Is she
dangerous?
Well, if she tests every possibility, it will take her over 5,000 years. So no,
your password is pretty secure.
However, you need to be careful about passwords. Dr. John Walters, a
computer science professor that we shall meet again in this volume, always
uses the login jwalters. Having a poor memory, he always starts his password
with his initials, jw, and ends with the last two digits of the year. The hacker
found this out, so in 2009 she worked out that his password had the form
jw****09. There are 604 = 12, 360, 000 passwords of this form. That sounds
like a lot, but in 3.6 hours she could run every possible password. Even if
she is very unlucky, and her computer does not find the actual password until
very late in the run, she could still hack into his account in an afternoon.
In order to protect people like Dr. Walters, Youface introduced some further
requirements. Your password cannot begin with the same two symbols as your
username, and the last two digits cannot be the last two digits of the year. In
2010, when he rebuilt his account, Dr. Walters could not choose any password
of the form jw****** or ******10.
How many possible passwords remained? We start with 608 possibilities,
and subtract the number of passwords that were banned. There were 608
passwords originally. There are 606 passwords of type jw******, and 606 of
type ******10. Subtracting these numbers leaves 608 − 2 × 606 . However, we
have taken away some passwords twice: those of form jw****10. There are
604 passwords like this, so we have “oversubtracted” 604 from the total. So
the final result is 608 − 2 × 606 + 604 .
This method of counting—subtract all objects in one class, do the same
with those in another class, then add back those that were common to both
classes—is the first case of the Principle of Inclusion and Exclusion. We shall
deal with this further in Chapter 5.
as: What is the maximum number of pieces remaining after cutting a pancake
with n cuts (none parallel and no three concurrent)?
2
1
3
5
4
6
7
The first thing we do is define a notation and try a few examples. This
is almost always a good start to any kind of problem. We let Pn be the
maximum number of pieces. Then it is easy to see that P0 = 1 (with no cuts,
the pancake is still one piece) and P1 = 2. When we notice that P2 = 4,
we see the progression 1, 2, 4 and wonder whether we might have powers of
two; perhaps, we think, Pn = 2n ? This would make sense if each cut passes
through every region, so that each region is cut into two. However, this does
not happen, and we find P3 = 7, as we can see from Figure 1.1. A few more
tries will give us P4 = 11 and P5 = 16. Clearly, another approach is needed.
How many new regions do we get by adding a new cut? If we have n − 1
cuts in the pancake, and add another cut, the rules require that the new cut
must intersect each of the n − 1 old cuts. If we start the cut on the edge of
the pancake in the middle of a region, we cut along the pancake and cut off a
new region when we reach the first of the n − 1 old cuts. Then as we continue
cutting in a straight line, we intersect each of the other old cuts, cutting off a
new region when we do. Then at the end, we reach the edge of the pancake,
and we cut off a final piece. This means that we have added n pieces; one
for each of the original n − 1 cuts, and one when we reach the edge of the
pancake. This tells us that Pn = Pn−1 + n. This is a formula for Pn , but not
a nice one because we cannot easily calculate, for example, P100 without a
great deal of effort. We will work a little harder and see whether we can find
a more efficient formula.
We start by repeating the formula for larger values of n. We get P1 = P0 +1,
and P2 = P1 +2 = P0 +1+2, then P3 = P0 +1+2+3, P4 = P0 +1+2+3+4, and
so on. The pattern becomes clear, and we write Pn = P0 +(1+2+· · ·+n). Now
we nearly have our answer. The reader may be familiar with the formula for
1 + 2 + · · · + n or of the first n terms of any arithmetic progression; the story
goes that the eminent mathematician Carl Friedrich Gauss (see Appendix
C) found the sum of the first one hundred integers almost immediately by
realizing how the formula worked (for more details, see [16], p. 509). The
4 Introduction to Combinatorics
1 2 3 ... n−1 n
n n−1 n−2 ... 2 1
Each of these rows clearly sums to the same value, S. If we add the columns,
we find that each column adds to n+1, and there are n columns; thus the sum
of all elements in both rows is 2S = n(n+1). Thus 1+2+· · ·+n = n(n+1)/2.
This gives us, finally, our formula for Pn , the maximum number of pieces
after n cuts.
n(n + 1)
Pn = 1 +
2
Sudoku
Over the last few years we have seen a great surge of interest in the Sudoku
puzzle. For those few readers who have been vacationing on another planet,
the puzzle consists of a 9 × 9 array, partitioned into 3 × 3 subarrays (sub-
squares), in which some cells contain entries chosen from {1, 2, 3, 4, 5, 6, 7, 8, 9}.
The object is to complete the array so that every row, every column and every
subarray contains each symbol precisely once.
Sudoku was apparently invented by an American architect, Howard Garns
(see Appendix C), in 1979, but did not achieve great popularity until 1986,
when it started appearing in Japanese publications. Worldwide circulation
dates to about 2004. A nice history can be found in [137].
We’ll use the phrase Sudoku square for a completed 9 × 9 square that could
be the solution to a Sudoku puzzle. In a well-posed puzzle, there is one and
only one Sudoku square that completes the original partial array.
Figure 1.2 shows a typical Sudoku puzzle in the top left-hand position. It
needs a 1 in column 3. There are already 1s in the top left and bottom left
subsquares, so there is only one possible space in the column; the top right
array shows the 1 in place.
Now look at the top right subsquare. It needs a 2, 4, 5, and 7. The only
possible place for a 4 in this subsquare is the middle top. At first, it looks
as though the 5 can go in any of the other three vacant cells. However, the
second row is not available (the 2 must go there), and the 7 must go in the
last column (there is already a 7 in the seventh column, and the 4 filled up
the eight column). So the 5 only has one possible home. The completion of
the top right subsquare is shown in the lower left copy.
Continuing in this way, we obtain the Sudoku square shown at the lower
right of the figure.
The methods used in solving Sudoku are combinatorial in nature. However,
not many of the millions who play Sudoku realize that a Sudoku square is an
example of a combinatorial object, called a Latin square, that is widely used
in statistical and geometric applications. We shall study Latin squares in
Chapter 13.
Introduction 5
9 6 2 8 1 9 6 2 8
1
1 8 3 1 8 3
2 1 6 9 2 1 6 9
7 8 4 3 7 8 4 3
5 9 4 6 5 9 4 6
6 3 7 8 6 1 3 7 8
5 4 7 8 5 4 7 8
1 9 5 1 9 5
3 2 5 9 4 3 2 5 9 4
9 6 2 8 5 4 1 9 7 3 6 2 8 5 4 1
1 2 8 3 6 1 5 9 4 7 2 8 3
2 1 6 9 7 8 4 2 5 3 1 6 9 7
7 8 4 3 7 2 8 1 6 4 9 3 5
5 9 4 6 5 3 9 8 7 2 4 1 6
6 1 3 7 8 4 6 1 3 9 5 7 2 8
5 4 7 8 2 5 4 7 1 3 8 6 9
1 9 5 1 9 7 4 8 6 3 5 2
3 2 5 9 4 3 8 6 2 5 9 1 7 4
FIGURE 1.2: A Sudoku puzzle.
from the middle needle to the rightmost needle. This will cause no problems
since the disk on the rightmost needle is the largest, so that any disk may be
placed on it without violating a rule.
It is at least intuitively clear that this technique gives us the most efficient
way to move a stack of n disks. Clearly the basis case uses the fewest possible
moves (one move for one disk, three moves for two disks). Also, it seems clear
that there is no shorter way to move n + 1 disks than by moving the stack
of n disks first. Without going through a rigorous proof, it is at least very
plausible that our approach uses the fewest moves possible.
Now the hard part: How many plays does this method take for n disks?
We denote this (still unknown) quantity by Hn . Clearly, we have H1 = 1 and
H2 = 3. For any n > 2, we can compute Hn = 2 · Hn−1 + 1. This follows
because we use Hn−1 plays to move the n − 1 disks to the middle needle, one
play to move the largest disk to the rightmost needle, and another Hn−1 plays
to move the n − 1 disks from the middle to the rightmost needle.
This kind of formula for Hn , like the formula for Pn of the previous example,
is called a recurrence because the expression we are solving for “recurs” in
the equation. This does not give us a simple formula for Hn , but it gives us
a way to calculate it. We will run through a few values.
n 1 2 3 4 5
Hn 1 3 7 15 31
everyone else once. If Adam were going to play every other competitor exactly
once, he would play in two matchups; writing the initials of each player to
represent a game, the schedule could include ABCD and AEFG. But whom
will Beth play? One matchup is already given, ABCD. She cannot meet A,
C or D again, so the only possibility is BEFG. But a schedule cannot include
both AEFG and BEFG: pairs like EF would meet twice.
So they decided to try a schedule where everyone plays everyone else twice.
Everybody will have four games (each person must meet six opponents twice
each—12 appearances—and each game accounts for three). We may as well
assume Adam plays in ABCD. He must play against Beth again, and the two
matches AB... could have a total of four, three or two players in common.
If we try four players—that is, use the matchup ABCD again—Adam’s other
two games must be AEFG twice. But Beth has been scheduled against A, C
and D twice, so her other two matchups must each be BEFG, and EF (as well
as other combinations) has occurred too many times. Similarly, if there are
two games with three players in common, say ABCD and ABCE, we strike
problems: Adam plays twice more, and must meet both F and G twice. The
only possibility is ADFG, AEFG. But the same argument shows that we must
have BDFG and BEFG. Now F and G have played each other too often.
Okay, this argument shows that the two AB... matchups have no other
member in common, and the same must apply to all other pairs. So no
two games can have three players in common. Try to start with ABCD and
ABEF. Adam’s other two matchups have the form A...G, in order for him to
meet Greg twice. They cannot use B again, and ACDG would have three in
common with ABCD, so they try ACEG and ADFG (or ACFG and ADEG,
which would be equivalent, just exchange two names). The same argument,
avoiding three in common with the first two games, leads to either BCEG or
BCFG, and BCEG clashes with ACEG, so they chose BCFG and BDEG. The
final matchup is CDEF, and the schedule is
The players are very happy—and then Helga joins their group. What now?
And what if other players join up?
Let’s write v for the number of players, and say each pair plays together λ
times. Then each player has λ(v − 1) instances of an opponent. Each matchup
accounts for three of these. So each player takes part in λ(v − 1)/3 games.
You cannot schedule partial games, so λ(v − 1) must be a multiple of 3. So,
for v = 8, λ must be 3 or 6 or . . . . For the 8-player version, the smallest
possible case is λ = 3, in which case there will be 14 games and each player
is in three of them.
The wargamers didn’t feel up to calculating a schedule for 14 games, so
they started playing the 7-player version again. Each week they scheduled
one game. Each week the other three players came to watch, and played a
game with Helga. And, at the end of seven weeks, they realized they had
Introduction 9
tossing a coin for each player, so that the allocations are independent and
each player has a 50-50 chance of red or black. We’ll assume they are telling
the truth, and we’ll also assume the players don’t try to concoct any type of
cheating scheme. What is the team’s best plan?
One obvious strategy would be for the team to nominate one of their number
who will always say “red” while the other two players always pass. This
would give them a 50% chance of winning the prize. Can they do better?
Most people, and in fact most mathematicians, initially think not. Since
each person’s hat color is independent of the other players’ colors and no
communication is allowed, it seems impossible for them to learn anything just
by looking at one another; all the players can do, it seems, is guess.
But in three out of four cases, we expect two of the players will have hats of
the same color and the third player’s hat will be the opposite color. The group
can win every time this happens if the players follow the following strategy:
Once the game starts, look at the other two players’ hats. If you see two hats
of different colors, pass. If they are the same color, guess that your hat is
the opposite color. Every time the hat colors are distributed two and one,
one player will guess correctly and the others will pass, and the team will win
the game. When all the hats are the same color, all three players will guess
incorrectly and the group will lose; but on average this will happen in only a
quarter of cases.
There are eight ways the hats can be distributed: RRR, RRB, RBR, RBB,
BRR, BRB, BBR and BBB (from left to right). Suppose the game was played
eight times, and suppose it just so happened that every possible combination
occurred once. In the first and last cases, all three players make the wrong
guess; in the other six there is just one correct guess. So, of the twelve guesses,
half are right and half are wrong, as you would expect.
How about more players? With four team members, the easiest strategy is
to tell one player to stay silent throughout. The other three don’t even look at
that player! They play as they would if member number four was not there:
each looks at the remaining two players and proceeds as if it was a team of
size three. They still have a 75% chance of winning.
The Hat Game problem was introduced by Todd Ebert in his dissertation
[28], and is in fact related to error-correcting codes. It has been discussed in
the press [90], and a recent survey paper is [17]. We’ll examine the problem
further, and explain the connection to error-correcting codes in Chapter 12.
B
D
The problem was to find a walk through the city that would cross each
bridge once and only once, and visit all four parts. The only way to go
between the different pieces of land was to cross the bridges.
So we have a combinatorial problem. We have a set with seven elements—
the seven bridges—and we need to find out whether they can be arranged in a
certain way, specifically so that the corresponding bridges could be traversed
in the given order.
The solution is very easy. Look for example at the north bank of the river,
part A. Whenever you walk over a bridge that leads to A, your next bridge
must take you back out of A. So walking into A and out again uses up two
bridges (we say “uses them up,” because you cannot cross a bridge twice).
There are three bridges; the walk must take you onto A and off again once,
and there is one bridge left over. The only possibility is that the walk must
start or finish in A (but not both).
The same argument can be applied to C and D (with three bridges each),
and to B (five bridges, so you walk through B twice). Each part of town is
either the start or finish. But a walk can have only one start, and only one
finish, and there are four parts of town! This is clearly impossible, so there is
no such walk.
Of course, Euler proved that no walk is possible. But he did much more.
As we said, he essentially invented graph theory and showed how it could be
used to represent any set of islands and bridges, or indeed any set of towns and
roads joining them, and concocted an algorithm for traversability problems.
We shall look at his methods in Section 11.1.
12 Introduction to Combinatorics
similar diagrams were studied earlier by Leibniz and Euler, and related ideas
were studied by Lull as far back as the thirteenth century (see, for example,
[5]). It has recently become fashionable to refer to “Euler diagrams,” but
Venn was primarily responsible for their modern usage.
For example, the Venn diagrams or R ∪ S, R ∩ S, R, R\S and R ∩ S ∩ T
are shown in Figure 1.5.
R S R S
R ∪S R∩S
R R S
_
R R\S
R
S T
R∩S∩T
S × T = {(s, t) : s ∈ S, t ∈ T }.
The obvious equivalence relation is equality, on any set. In sets other than
number sets, equal objects are often called “equal in all respects.” More
generally, an equivalence relation can be considered as a statement that two
objects are “equal in some (specified) respects.” One example, on the integers,
is the relation α, where a α b is true if and only if a = ±b—a and b have the
same absolute value. Another, is congruence, on the set of all plane triangles.
Equivalence relations give us an alternative way to discuss multiple ele-
ments. You can view a multiset as an object based on a set of distinct ele-
ments on which an equivalence relation has been defined, so that the elements
of a multiset are the equivalence classes of the underlying set.
One of the most important proof techniques for working with finite sets or
with sets of integers is the method of mathematical induction, the application
of the principle of mathematical induction:
Suppose the proposition P (n) satisfies
(i) P (1) is true; and
(ii) for every positive integer n, whenever P (n) is true, then P (n + 1) is
true.
Then P (n) is true for all positive integers n.
If you are not familiar with induction, or need to review the topic, we treat
it in detail in Appendix A.
nine entrees, and seven desserts, the number of meals consisting of one salad
and one entree and one dessert is 2 × 9 × 7 = 126.
Although these principles seem painfully obvious, each may be proved by
results from set theory; for instance, the multiplication principle follows from
the fact that the cardinality of a Cartesian product of sets is the product of
the cardinalities of the underlying sets. However, we prefer to emphasize the
uses rather than the proofs of these principles.
Example 1.1: We wish to have lunch at a fast-food place, and there
are three within walking distance. One place offers eight soft drinks, seven
sandwiches, and two choices of a “side dish” (French fries or onion rings);
another offers only six drinks, but 10 sandwiches and two sides; and the last
(a coffee shop) offers 16 drinks, five sandwiches, and only one side. How many
different lunches are possible?
The addition principle says that (because we can eat lunch at only one
place) the answer is the sum of the number of ways to eat lunch at each place.
The multiplication principle says that each place has a number of options
equal to the product of the options at each stage: drink, sandwich, and side.
So the first restaurant offers us 8 × 7 × 2 = 112 possibilities; the second,
6 × 10 × 2 = 120; and the third, 16 × 5 × 1 = 80. Altogether, then, there are
112 + 120 + 80 = 312 possibilities for lunch.
The next few examples will introduce some mathematical concepts that
may already be familiar to the reader. These concepts arise frequently in
enumeration problems. The reader should already be familiar with n! to
denote the product 1 · 2 · · · · · n. By convention, we assume 0! = 1! = 1.
Example 1.2: A set has n distinct elements. How many subsets does it
have?
We line the elements of the set up in some order; beneath each, we will
place a mark if the element is in our subset, and no mark if the element is
not. We will make n decisions as we go through the list of elements, and each
decision has two alternatives, mark or no mark. Since no decision will affect
any other decision, we see that there are 2n subsets of a set of n elements.
Example 1.3: Suppose we have five tunes stored on our portable digital
music player, and we wish to listen to each of them one after another. How
many ways are there to arrange the playlist?
We have five tunes, so there are five possibilities for the first tune. Once
we have chosen this tune, then regardless of which tune we choose to play
first there are four tunes left (because we don’t wish to repeat a tune). After
we choose the second tune, there are three possibilities left, and so on. The
result is that we may choose a playlist in 5! = 5 × 4 × 3 × 2 × 1 ways, by
the multiplication principle. In more general terms, we find that there are n!
Introduction 17
Example 1.4: A license plate consists of three letters of the alphabet and
three digits from 0 to 9, with the letters preceding the digits. How many
license plates are possible? How many are possible if we do not use any letter
twice? How many are possible if we may use letters twice but not digits? How
many if we do not use either twice?
We imagine six boxes in a row as shown.
For the first box, we may choose any of the 26 letters, so we have 26 choices.
For the first question, where we may repeat letters and digits, we have 26
possible choices for each of the next two boxes as well. The last three boxes
each have 10 possibilities. It follows from the multiplication principle that
there are 263 · 103 possible license plates. If we may not repeat a letter, then
we must work a little harder; the second box has only 25 possible letters, and
the third has only 24. We then get 26 · 25 · 24 · 103 possible plates. In the
same way, there are 263 · 10 · 9 · 8 plates where letters may be repeated but
digits may not; and 26 · 25 · 24 · 10 · 9 · 8 possible plates where neither may be
repeated.
Example 1.5: How many n-digit numbers in base k are there if we do not
allow a leading digit of 0? How many numbers without leading zeros in base
k are there with at most n digits?
We recall that a number in base k has possible digits 0, 1, . . . k − 1, so that
each of the n digits may be assigned any of the k symbols, except for the
first. We apply the multiplication principle to see that there are (k − 1) · k n−1
possible numbers. To find how many numbers of at most n digits in base k
there are, we may simply permit leading zeros; so the number 1 (in any base)
might be considered a “five-digit number” 00001. We find that there are k n
such numbers.
1.4 Graphs
A great deal of mathematics has been done concerning collections of subsets
of two elements of a larger set. In that case the members of the universal set
are often represented graphically, as points in a diagram, and the set {x, y} is
represented by a line drawn joining x and y. Provided the universal set is not
empty, such a structure is called a graph. The sets are called edges (or lines),
and the elements of the universal set are vertices (or points). The universal
set is the vertex-set of the graph. For any graph G, we write V (G) and E(G)
for the sets of vertices and of edges of G.
The edge {x, y} is simply written xy, when no confusion can arise; x and
y are called its endpoints. When x and y are endpoints of some edge, we say
they are adjacent and write x ∼ y for short; the vertices adjacent to x are
called its neighbors. The set of all neighbors of x is its (open) neighborhood,
N (x). If x and y are not adjacent we write x 6∼ y.
Two vertices either constitute a set or not, so a graph can never contain two
edges with the same pair of vertices. However, there are some applications
where two edges joining the same vertices might make sense. For this reason
we sometimes talk about networks or multigraphs in which there can be several
edges joining the same pair of vertices; those edges are called multiple edges.
Another generalization is to allow loops, edges of the form xx. There is no
very good term for a graph-type structure in which loops are allowed, and we
will usually call one of these a looped graph or looped network or network with
loops although strictly speaking it is not a graph or network at all. Moreover,
when no confusion arises, the word graph can be used for any generalized
graph.
Any binary relation can be represented by a diagram. If ρ is a binary
relation on the set S, the elements of S are shown as vertices, and if xρy is
true, then an edge is shown from x to y, with its direction indicated by an
arrow. Provided the set S is finite, all information about any binary relation
on S can be shown in this way. Such a diagram is called a directed graph
or digraph, and the edge together with its arrow is called an arc. If ρ is
symmetric, the arrows may be dropped and the result is a graph (possibly
with loops).
Several families of graphs have been studied. Given a set S of v vertices,
the graph formed by joining each pair of vertices in S is called the complete
graph on S and denoted KS . Kv denotes any complete graph with v vertices.
As you would expect, we often call K3 a triangle. The complete bipartite
graph on V1 and V2 has two disjoint sets of vertices, V1 and V2 ; two vertices
are adjacent if and only if they lie in different sets. We write Km,n to mean a
complete bipartite graph with m vertices in one set and n in the other. K1,n
in particular is called an n-star . Figure 1.6 shows copies of K6 and K3,4 .
Introduction 19
Suppose H is a graph all of whose vertices and edges are vertices and edges
of some graph G—that is, V (H) ⊆ V (G) and E(H) ⊆ E(G). Then H is a
subgraph of G; we write H ≤ G. Every graph G has itself as a subgraph;
if H is a subgraph of G but H 6= G, H is a proper subgraph of G, and we
write H < G. In particular, if S is some set of vertices of G then hSiG is
the subgraph consisting of all edges of G with both endpoints in S. If G
is a complete graph whose vertex-set contains S then the subscript “G ” is
dropped, and hSi is the complete subgraph based on S. Any subgraph of a
complete bipartite graph is itself called bipartite.
Instead of saying Figure 1.6 shows two graphs, we could say it is a single
graph that consists of two separate subgraphs, with no edges joining one part
to the other. We call such a graph disconnected ; a graph that is all in one piece
is called connected. The separate connected parts of a disconnected graph are
called its components.
The graph G is trivially a subgraph of the complete graph KV (G) . The set
of all edges of KV (G) that are not edges of G will form a graph with V (G) as
its vertex set; this new graph is called the complement of G, and written G.
More generally, if G is a subgraph of H, then the graph formed by deleting
all edges of G from H is called the complement of G in H, denoted H − G.
The complement K S of the complete graph KS on vertex set S is called a null
graph; we also write K v as a general notation for a null graph with v vertices.
Figure 1.7 shows a graph and its complement.
A A
B C B C
D E D E
G G
FIGURE 1.7: A graph and its complement.
20 Introduction to Combinatorics
Proof. Suppose the graph or multigraph has e edges; label the edges, say
y1 , y2 , . . . , ye . Consider a list in which each edge appears twice, once for each
endpoint. For example, if y1 has endpoints x4 and x7 , you might make entries
y1 : x4 and y1 : x7 . Vertex x will appear in precisely d(x) entries, so the total
number of entries equals the sum of the degrees of the vertices. On the other
hand, each edge appears twice, so the total number of entries equals twice the
number of edges.
COROLLARY 1.1.1
In any graph or multigraph, the number of vertices of odd degree is even. In
particular, a regular graph of odd degree has an even number of vertices.
Suppose you encounter two graphs with exactly the same structure but
different vertex-sets. For example, look at Figure 1.7 again; the two subgraphs
with vertex-sets {B, D, E} and {C, D, E} are both triangles. There is no
real difference between them until you need to consider the meaning of the
vertices. Formally, we say two graphs G and H are isomorphic if there is
a one-to-one correspondence between their vertex-sets V (G) and V (H) such
that two vertices of G are adjacent if and only if the corresponding vertices
of H are adjacent. For example, any two complete graphs with v vertices are
isomorphic.
Not all graphs with the same number of vertices are isomorphic; for ex-
ample, the graph G of Figure 1.7 and its complement are quite different, but
both have five vertices.
SDR for D to be a way of selecting a member xi from each set Bi such that
x1 , x2 , . . . are all different.
As an example, consider the sets
1, 2, 3, 5, 4, 6
(where the representatives are listed in the same order as the sets). There are
several others. On the other hand, the sets
have no SDR.
If the collection of sets D is to have an SDR, it is clearly necessary that
∪B∈D B have at least as many elements as there are sets in D. The example
above shows that this is not sufficient.
Exercises 1A
1. In each case, represent the set in a Venn diagram.
(i) R ∪ S ∪ T (ii) R ∪ S ∪ T
2. Show that the Hat Game team has at least a 75% chance of winning,
for any number of players greater than three.
3. Find a formula for the sum of the first n odd positive integers,
1 + 3 + . . . + (2n − 3) + (2n − 1)
(i) using Gauss’s formula for the sum of the first n positive integers;
(ii) using induction.
4. The seven wargamers decide to play a new game, where players compete
in groups of three. Show that they can find an equitable schedule of
seven games.
7. A phone store has four models of Samsung phones, three kinds of HTC
phones, and two models of Apple phones. In how many ways can we
purchase a phone from this store?
10. We have recorded eight movies and we want to watch three of them
tonight. How many ordered sequences of three of the eight movies are
possible?
11. A state has license plates consisting of two letters and four digits. How
many license plates are possible?
12. Suppose a set X has 2n + 1 elements. How many subsets of X have n
or fewer elements?
13. What are the degrees of the vertices in these graphs?
14. How many edges does the star K1,n have? What are the degrees of its
vertices?
15. A graph has 48 edges. There are no isolated vertices. What are the
minimum and maximum numbers of vertices the graph can have?
16. Eight people attend a meeting. At the beginning various people shake
hands. In total there are eighteen handshakes.
(i) Show that there is at least one person who shook hands at least
five times.
(ii) Is it possible there were exactly three people who shook hands an
odd number of times?
17. Do there exist SDRs for the following sets?
(i) 12, 145, 12, 123
(ii) 123, 145, 12, 13, 23.
Exercises 1B
1. The seven wargamers have become more ambitious. They wish to play
a tournament as follows: each week two groups of three (with no one in
common) play; the seventh member acts as host. Find a schedule for
them to do this in seven weeks.
2. In each case, represent the set in a Venn diagram.
24 Introduction to Combinatorics
(i) R ∪ (S ∩ T ) (ii) (R ∩ S) ∪ T
4. A ball is dropped from a height of 10 feet. Each time it hits the ground,
it bounces back to half the previous height. How far will it have traveled
when it hits the floor for the tenth time?
5. A furniture store has in stock four square dining tables, six expandable
rectangular dining tables, and two circular dining tables. In how many
ways can we purchase a dining table from this store?
6. A furniture store has three kinds of dining tables, six different sets of
dining room chairs, and three kinds of sideboard. In how many ways
can we purchase a dining room set consisting of a table, a set of chairs,
and a sideboard?
9. There are nine new videos we want to see on YouTube, but we only
have time to watch four of them right now. How many ways are there
to watch four of the nine videos in some particular order?
10. A state has a license plate that consists of two letters, three digits, and
one letter. How many license plates are possible?
Problems
At the end of the party, the hostess asks each person (other than herself, of
course), “with how many people did you shake hands?” It turns out that no
two of them shook hands with the same number.
(i) With how many people did the hostess shake hands?
(ii) With how many people did her husband shake hands?
(iii) Generalize this to the case of n couples.
Problem 8: We have five student organizations O1 , O2 , . . . O5 , each of which
wishes to send a student ambassador to the National Congress of Useless
Student Organizations. National Congress policy decrees that no student
may represent two organizations, so we require an SDR of the memberships
of the organizations. Of all students in these organizations, only five (A, B,
C, D, and E) are interested in being ambassadors. Now, O1 contains A and
C; O2 contains A, B, C, and D; O3 contains A and C; O4 contains B, D,
and E; and O5 contains A, C, and D.
(i) Find an SDR from among the interested students.
(ii) Find a student and organization such that if the student resigns from
the organization, no SDR is possible.
(iii) Find a different student and organization such that if the student resigns
then no SDR is possible.
(iv) Is it possible that if one of these five students were to join one other
organization, part (ii) would have no solution? Prove your answer.
Chapter 2
Fundamentals of Enumeration
In this chapter we explore some applications of the two principles that were
introduced in Section 1.3.
Proof. There are n possible choices for the first object, (n−1) for the second,
and so forth, until we find that there are n − k + 1 possible choices for the kth
object. The Multiplication Principle tells us that there are n(n−1) . . . (n−k+
1) arrangements altogether. When we divide n! by (n − k)!, this is precisely
the result.
Example 2.2: How many ways are there for an awards committee to
award three distinct scholarships among 12 students entered?
27
28 Introduction to Combinatorics
There are six mathematicians who could serve and we must choose two
of them; this may be done in C(6, 2) = 15 ways. We select the biologists
in one of C(10, 3) = 120 ways. The computer scientists are chosen in one
of C(5, 3) = 10 ways. By the Multiplication Principle, we have a total of
15 × 120 × 10 = 18, 000 possible committees.
Example 2.5: For the new bioinformatics program of the previous exam-
ple, we find that Dr. John Walters of computer science and Dr. Walter Johns
Fundamentals of Enumeration 29
n
2.2 Applications of P (n, k) and
k
Here we discuss some problems whose solutions involve counting permu-
tations and combinations, as well as a generalization of the concepts. In
particular, the student is probably aware that the symbol C(n, k) is called
a binomial coefficient . A “subscripting technique” proves the theorem that
explains this name.
COROLLARY 2.3.1
n n
=
k n−k
30 Introduction to Combinatorics
COROLLARY 2.3.2
n
X n
= 2n
k
k=0
COROLLARY 2.3.3
n
X
k n
(−1) =0
k
k=0
Combinatorial identities often have two or more kinds of proofs. One kind
of proof for a theorem such as this is the algebraic proof, where we simply
write both sides of the equation, expand in factorials, and transform one side
into the other by means of elementary (and reversible) algebraic operations.
Another approach is to use a combinatorial proof, which involves showing
that each side of the equation counts the same set, or counts sets between
which a bijection exists. The combinatorial proof is often preferred because
it provides greater insight into the meaning of the identity.
Proof. Consider a set of n distinct objects, one of which we distinguish with
a label of some kind from the others. We count the number of ways to select
k of these objects. Clearly, there are nk ways to do this. Now, if we wish to
separate these subsets of size k according to whether or not they contain the
distinguished object, how many of each kind are there? The sets containing
the distinguished object may be formed by taking the object and choosing
k − 1 of the remaining objects of the n − 1; so there are n−1
k−1 subsets of size
k that contain our distinguished element. Similarly, if we do not include the
Fundamentals of Enumeration 31
n\k 0 1 2 3 4 5 6
0 1
1 1 1
2 1 2 1
3 1 3 3 1
4 1 4 6 4 1
5 1 5 10 10 5 1
6 1 6 15 20 15 6 1
All
All
All
of which 7 must be “E” and 5 must be “N.” How many such strings are there?
Clearly C(12, 5) = 792.
Example 2.7: In how many ways can we make this walk if we determine
to walk along the block marked b1 in Figure 2.1? How many ways if the block
marked b1 is blocked off and we must avoid it?
The first question is simple enough; to guarantee we walk along block b1,
we must walk from our starting point (denoted (0, 0)) to the westmost point
of the block (at (2, 2)); then walk from the end of that block (at (3, 2)) to
our destination at (7, 5). The Multiplication Principle gives us the number of
ways to do this; it is C(4, 2)·C(7, 3) = 210.
The second question requires us to take the 792 total ways to walk from
one corner to the other and subtract the 120 ways that entail walking down
block b1; this gives us 582 ways to walk without going down block b1.
We will see other problems involving counting lattice paths like this else-
where in the book. You should also see the exercises and problems at the end
of the chapter that make use of the blocks labeled b2 and b3.
Example 2.8: Consider the two questions: How many ways can we rear-
range the letters of the word KEPT ? How many distinct rearrangements are
there of the word KEEP ?
The first question is simple. Because there are four distinct letters, we may
arrange them in 4! different ways, using Theorem 2.1. The second question,
however, requires some effort. We begin by using subscripts, as we did in
the proof of Theorem 2.3. The word KE1 E2 P now consists of four distinct
symbols, and there are accordingly 4! distinct rearrangements. However, when
we remove the subscripts, there are 2! ways of permuting the two Es. Thus, we
have 4!/2! = 12 rearrangements. This is a small enough number we can check
by listing them explicitly. We find EEKP, EEPK, EKEP, EKPE, EPEK,
EPKE, KEEP, KEPE, KPEE, PEEK, PEKE, and PKEE. Each of these turns
into two permutations if we leave the subscripts on the E s.
Example 2.9: In how many distinct ways can we rearrange the letters of
MADAM IM ADAM ?
Fundamentals of Enumeration 33
There are 11 letters, of which four are M, 4 are A, two are D, and one is I.
Thus, we have 11!/(4!·4!·2!·1!) = 34, 650. We divide by 4! for the Ms, 4! for
the As, and 2! for the D.
where the sum is over all ways to write n as a sum of non-negative integers
k1 + k2 + · · · + kr .
Example 2.11: If we are given a dozen identical chocolate eggs and wish
to arrange them into four distinct Easter baskets, in how many ways can we
do this? In how many ways can we do this if each basket is to receive at least
one egg?
We are not concerned with fairness; we might give all twelve eggs to one
basket, for instance, and do not need to put three eggs in each. Because the
baskets are distinct, a solution in which all 12 eggs go into the first basket is
different from one in which all 12 go into the second, third, or fourth baskets.
We set this problem up by lining up the twelve eggs, and inserting three
dividers between eggs to indicate which eggs go into which basket. Thus a
diagram like this indicates three eggs in each basket:
OOO|OOO|OOO|OOO
If all twelve eggs were to go into the first basket, the diagram would be this:
OOOOOOOOOOOO|||
Each vertical divider separates the eggs that go into one basket from the
eggs that go into the next. A little thought will reveal that each diagram
corresponds to a distinct way to arrange the eggs, and each arrangement
of eggs is represented by exactly one diagram. Thus we have a one-to-one
correspondence between diagrams and ways to arrange the eggs, and we may
count the diagrams to solve the problem.
How many diagrams are there? With 12 Os and three |s, we have 15 symbols
altogether; and three of these symbols must be |. There are 15 3 = 455 ways
to arrange the eggs. Now, if each basket must contain at least one egg, we
merely place one of our twelve eggs into each basket. This leaves us 8 eggs
and four distinct baskets (each with an egg in it), and we repeat the problem
by taking 8 eggs and three dividers, to get 11
3 = 165 ways.
We use the reasoning of the foregoing examples to establish the next theo-
rem.
Proof. We create a string of length n+k −1 that will consist of n objects and
k − 1 dividers. The ith divider will separate the objects that go into class i
from the objects that go into class i + 1. Because there are C(n + k − 1, k − 1)
such strings, there are C(n + k − 1, k − 1) ways to separate the objects.
Example 2.12: We are organizing a party for small children and need to
buy 18 party hats; the store has 5 different designs. In how many ways can
we select 18 hats, assuming any hats with the same design are identical and
the store has an unlimited number of hats of each design?
Fundamentals of Enumeration 35
At first glance, this problem does not appear to be solvable using the the-
orem. However, with a little thought we can see that it may be stretched to
apply. Imagine that we have 18 identical hat boxes, and we wish to place the
hat boxes into one of five categories depending on the design of hat that it will
hold. Then by Theorem 2.7 there are C(18 + 5 − 1, 5 − 1) = C(22, 4) = 7, 315
possibilities.
This example illustrates an idea that arises often enough in different con-
texts that it deserves its own theorem. Just as Theorem 2.5 dealt with the
permutations of a multiset, this deals with combinations of a multiset.
Proof. We imagine n boxes. Each box is to hold one item, and each is to be
classified into one of k classes, depending on which kind of item the box is to
hold. Again, we use Theorem 2.7 to show that there are C(n+k−1, k−1) ways
in which to classify the boxes. We fill each box with a copy of the object of
that type, and after discarding the boxes, we have our desired combination.
There is clearly a bijection between the ways to classify the boxes and the
ways to select the items from the multiset.
Another common counting problem is that of cyclic permutations. Suppose
we wish to seat n people at a round table with identical seats. At first glance,
this laudably Arthurian arrangement might be accomplished by lining up
our people in one of the n! possible ways, and simply seating them in order.
However, this actually overcounts the number of ways to seat people. Suppose
we moved each person one or more places to the left. This would be the same
seating arrangement, because the same people would be seated next to each
other. Since there are n ways to choose the seat where a selected person sits,
and any of the n seating arrangements we obtain by rotating people left or
right are equivalent, we see that there are actually n!/n = (n − 1)! distinct
cyclic seating arrangements.
Example 2.13: Suppose that we are to seat 10 children at a circular table.
First of all, in how many distinct ways can this be done? In how many if two
of the children are siblings and always sit next to one another? In how many,
if two of the children are mischievous siblings who on no account may sit next
to one another if sanity is to be preserved?
The first question is a simple matter of applying the formula; there are
10!/10 = 9! = 362, 880 distinct seatings. The second question takes some
more thought. Suppose we “glue” the siblings c0 and c1 together into a single
unit. We may do this in two distinct ways; we may glue them so that c0
36 Introduction to Combinatorics
There are very many works that discuss the uses of binomial coefficients,
identities involving them, and interesting uses. Among others, the reader may
benefit from [41] and [63].
Example 2.14: For instance, one poker hand is known as two pair ; this
means that of the five cards, we have two cards of one rank (say, the eight
of clubs and the eight of diamonds); two cards of a different rank (such as
deuces of clubs and spades); and a fifth card of a different rank (say, jack of
clubs). How many such hands are there?
Finally, of the 11 remaining ranks, we would choose the jack and choose clubs
from the four possible suits.
Suppose instead we chose a deuce first, and chose a spade for the first suit
and a club for the second. Then we chose an 8, and chose a diamond for the
first suit and a club for the second. Then we again chose the jack and clubs for
the fifth card. Notice that, even though we made distinctly different choices,
we still obtain the same hand! This means that each possible hand is being
counted more than once.
How might we choose this hand correctly? The problem arose because the
poker hand does not care whether the eight or the deuce was dealt first; and
it makes no difference for the eight whether we choose diamonds or clubs first.
Thus, we must choose both pairs at once. Now consider that we want two
ranks for our two pairs, and we wish to choose them from the thirteen ranks
available; that is 13 or 78. Now we choose two suits for one of the pairs; we
2
4
can do this in 2 or 6 ways. Another 42 selects the two suits for the second
pair. Now, as before, we have 11 ranks remaining and four suits for each rank.
Now our total is 78 × 6 × 6 × 11 × 4 or 123, 552. This is exactly one-eighth of
the total we had before (and is correct).
Example 2.15: A flush is a poker hand in which each of the five cards is
of the same suit; a straight flush is a flush in which the cards are consecutive,
as the 4, 5, 6, 7, and 8 of clubs. A royal flush is a straight flush consisting of
the 10 through ace. How many of each of these hands are there?
Clearly, there are only four royal flushes; one for each suit. (The royal flush
is the strongest hand in poker because it is the rarest.) How many straight
flushes are possible if we do not count royal flushes? We count according to
the lowest card. The ace may be the lowest or the highest card, so a straight
flush may have as its lowest card ace, deuce, trey, and on through 9. Since a
straight flush is entirely determined by its lowest card, and since there are 9
possible lowest cards in each of 4 suits, we have 4 × 9 = 36 straight flushes
that are not royal flushes. Finally, to count flushes, we choose a suit in 4
ways; we choose five cards from that suit in 13
5 ways; and we subtract the
straight and royal flushes from this total. This gives us 5, 108 possible flushes
that are not straight flushes or royal flushes.
2.5 Algorithms
Because permutations have such a broad range of applications, we present
two algorithms that may be used to generate permutations. Easy modifica-
tions of these algorithms may be used to produce particular kinds of permu-
tations, or to produce combinations. The first algorithm will produce a list
of all n! permutations on n letters.
Permutation-Generating algorithm: If n = 1, then return the list
consisting only of the letter a1 . If n > 1, then use the algorithm to generate
the list of all permutations on n − 1 letters, using the symbols a1 , . . . an−1 .
Make n copies of each permutation on this list. For each permutation, there
are n places where the new symbol an may be placed (before the first symbol,
between the first and the second, and so on until it is placed at the end). For
the ith copy of this permutation, place an in the ith position, and repeat until
all permutations have been treated this way.
This will become clearer with an example. Consider the case n = 2; we
use the algorithm to generate all permutations consisting of one letter, and we
make n copies of this permutation. This gives us two copies of the permutation
a1 .
The first copy gets an a2 in front; the second copy gets an a2 behind it. This
gives us the two permutations a2 a1 and a1 a2 , which are all the permutations
on two letters. Now we will work through the case of n = 3 in more detail.
The algorithm has given us both permutations on two letters, and we make
three copies of each, which we display in the diagram below.
a1 a2 a2 a1
a1 a2 a2 a1
a1 a2 a2 a1
We now interleave the a3 (boldfaced for clarity) within each to generate all
six permutations on three letters.
a 3 a1 a2 a 3 a2 a1
a1 a 3 a2 a2 a 3 a1
a1 a2 a 3 a2 a1 a 3
The result is the set of six permutations on three letters. This algorithm is
fairly well known, and is discussed in, among other sources, [43] and [13]; our
approach follows that of Brualdi[13].
Often, what is desired is not the set of all permutations on n letters, but
just one, perhaps chosen at random. While this could easily be accomplished
with the foregoing algorithm (merely generate all n! permutations on n letters
Fundamentals of Enumeration 39
and select one at random), the time and space required for even moderate-
sized values of n is prohibitive. Accordingly, we present an algorithm to select
a permutation on n letters at random.
Random permutation algorithm: Create a list of all n letters in
any order. Each letter is unmarked. Now, for each i between 1 and n, choose
an unmarked letter at random. Now, place that letter in position i of the
permutation and mark the letter in the list. Continue until all letters have
been chosen. No letter may be used twice because at each step the selected
letter is marked so that it cannot be chosen at a later step.
Exercises 2A
1. A program for generating random computer passwords gives one lower-
case letter, one upper-case letter, two digits (0 through 9), and three
letters that may be upper-case or lower-case. How many possible pass-
words can this program produce?
2. At one time, area codes were three-digit numbers with the second digit
0 or 1 and the first digit greater than 1. How many area codes were
possible under this system? How many are possible if we don’t allow 1s
in both the second and third digit (so as not to conflict with 911, 411,
etc.)?
3. A bookstore has a large box of very old books from an estate sale, and
the owner wishes to display one book from the box in each of five window
displays. If there are 24 books in the box, how many ways can this be
done?
5. How many of the first million positive integers contain exactly one 3,
one 5, and one 7?
6. A student decides that time is available to join no more than one social
networking site. Of four sites recommended, the student has three ac-
quaintances on the first, five on the second, six on the third, and four on
the fourth. Once joined to any site, the student has for each acquain-
tance the option to befriend or not to befriend that acquaintance. How
40 Introduction to Combinatorics
many possible outcomes are there of the process of choosing a site and
befriending or not befriending each acquaintance on the site?
7. A student decides that time is available to join exactly two social net-
working sites. Of four sites recommended, each has four of the student’s
acquaintances. Once joined to a site, the student has for each acquain-
tance the option to befriend or not to befriend that acquaintance. How
many possible outcomes are there of the process of choosing two sites
and befriending or not befriending each acquaintance on the site? As-
sume that the acquaintances on each site are different.
8. A student decides that time is available to join exactly two social net-
working sites. Of four sites recommended, two have four of the student’s
acquaintances, and two have five. Once joined to a site, the student has
for each acquaintance the option to befriend or not to befriend that
acquaintance. How many possible outcomes are there of the process of
choosing two sites and befriending or not befriending each acquaintance
on the site? Assume that the acquaintances on each site are different.
9. A student wishes to celebrate with a good friend. She has four friends
from which to choose, and one of these friends is under the age of 21.
The restaurants that she may choose from include three that do not
serve anyone under 21 due to state liquor laws, and four with no such
restriction. How many possible ways can the student celebrate assuming
she takes only one friend out? How many ways if she can afford to take
two of her friends out?
10. There are six tutors who are available to handle the 2:00 PM shift at
the Tutoring Center. In how many ways can we select three to assign
to that shift?
15. Refer to Figure 2.1. Compute the number of ways to walk from the
southwest corner to the northeast corner if we require that we pass
along block b2. Use this result to count the number of ways if block b2
is closed off and cannot be entered.
16. In how many distinct ways can we arrange the letters in the phrase
SLEEPING STEEPLES ?
19. A popular brand of mobile phone cover comes in eight different colors.
We wish to buy three covers. In how many ways can we do this if any
two covers of the same color are considered identical?
Exercises 2B
1. A program for generating computer passwords produces two lower-case
letters, one upper-case letter, three digits, and two letters that may
be either upper-case or lower-case, in that order. How many possible
passwords can this program generate?
2. A game store has 10 new games; the manager wants to devote each of
three distinct displays, one to each of three of the new games. How many
ways can the manager select three games, one for each of the displays,
in order?
7. There are eight tutors available to handle the 4:00 PM shift at the
Tutoring Center. In how many ways can we choose three of them to
assign to that shift?
11. Refer to Figure 2.1. Compute the number of ways to walk from the
southwest corner to the northeast corner if we require that we pass
along block b3. Use this result to count the number of ways if block b3
is closed off and cannot be entered.
12. How many distinct rearrangements of the letters SNIP TIN NIT PINS
are there?
14. There are seven identical memory cards that we wish to distribute
among four teenagers for use in their MP3 music players. In how many
ways can we do this? In how many ways if each of the teenagers is to
get at least one memory card?
Problems
she take two of her friends out to celebrate without violating any of these
restrictions?
Problem 14: Modify the algorithm that produces a random permutation on
n letters to obtain an algorithm to produce a random permutation of k of the
n letters, for any given k ≤ n.
Problem 15: Produce an algorithm to choose a random subset of order k of
a set of n letters.
Chapter 3
Probability
3.1 Introduction
In this chapter we explore some aspects of probability. We talk about
chance in various ways: “there is a good chance of rain today,” “they have no
chance of winning,” “there is about one chance in three,” and so on. In some
cases the meaning is very vague, but sometimes there is a precise numerical
meaning. Probability is the term for the precise meaning.
45
46 Introduction to Combinatorics
are also decks containing jokers.) Each suit contains an ace, king, queen, jack,
10, 9, 8, 7, 6, 5, 4, 3 and 2, and these are called the 13 denominations. The
cards are ordered as shown, with the ace highest; for some purposes the ace
also counts as the low card (the “one”). When a problem says “a card is dealt
from a standard deck” it is assumed that all possible cards are equally likely,
1
so the probability of any given card being dealt is 52 . As there are four cards
of each denomination, the answer to a question like “what is the probability
4 1
of dealing a queen,” or any other fixed denomination, is 52 , or 13 .
Example 3.1: Suppose we have a game in which each of two players draws
a card from a standard deck of cards, and whoever draws the card of higher
rank wins; in the case that both cards have the same rank, we draw again. If
we draw first, and get (say) a jack, what is the probability that we win the
game?
We will win the game if the other player draws any of the cards below a
jack; we will tie or lose otherwise. In order to satisfy the assumption that
all elements of the sample space (all cards) have the same likelihood of being
drawn, we assume that the cards were well-shuffled. There are 40 cards below
the jack if we count the ace as low, but that is not usual; it is more common
to let the ace be the highest rank, so that there are nine ranks (deuce through
10) below the jack. Because there are four of each rank, that leaves 36 cards.
Since after we have drawn our jack there are 51 cards remaining in the deck,
the probability of a win is 36/51 or (reducing) 12/17.
Example 3.2: In the above game, suppose we see that our opponent,
having drawn first, draws a nine. What is the probability that we will not
lose?
We consider the question in two ways. First, we may take the probability
that we win and add it to the probability that we have a tie. In this case, we
may win with any rank from among10, jack, queen, king or ace; there are 20
such cards. We may tie with any other nine, and there are three nines besides
the one our opponent has drawn. This gives us 23 “non-losing” cards, so that
our probability of not losing is 23/51 (where the 51 is, as with the previous
example, the number of cards remaining after our opponent’s nine is removed
from the deck).
Another approach works as follows; there are 51 cards remaining in the
deck, and we will lose if we draw any of deuce through eight (seven ranks);
this gives us a probability of losing of 28/51. If we subtract these 28 losing
cards from the 51 cards remaining, we have (51 − 28)/51 = 23/51 as our
probability of not losing.
The last example demonstrates a standard technique in probability, the
technique of complementary events. Two events are complementary if they
form a partition of the sample space S, or if one is the complement (in the set
Probability 47
theory sense) of the other. To make the statement more compact, we introduce
the probability function P (E) that assigns to each event E its probability.
Example 3.3: The Florida LottoTM is a game in which players choose six
different numbers between 1 and 53 inclusive. If the player gets the same six
numbers as were randomly drawn by the lottery officials, he or she wins the
jackpot. If the player only gets five of the six numbers, it is a win of a few
thousand dollars; if only four numbers, less than a hundred dollars; and five
dollars for three numbers. Find the probability of each outcome.
The probability of getting the jackpot is quite small; the sample space
consists of all possible C(53, 6) ways to select six numbers from 1 to 53.
This is 22, 957, 480. Since only one of these will win the jackpot, the prob-
ability is therefore just over one in twenty-three million. The probability
of getting five of the six is somewhat more encouraging, though still small;
we choose five of the six winning numbers to go on a ticket, and then we
choose one of the 47 non-winning numbers to go with them. This gives us
C(6, 5)·C(47, 1) or 282 ways to get five of the six winning numbers. Accord-
ingly, our probability is 282/22957480 = 0.000012 or just over a thousandth of
a percent. Four of six gives us more leeway (as well as smaller prize amounts);
we have C(6, 4)·C(47, 2) possible tickets, or 16, 215 ways to get four of the six
winning numbers. The probability here is 16215/22957480 or 0.0007, about
seven percent of one percent. Finally, to get three of the six may be done in
C(6, 3)·C(47, 3) = 324, 300 ways, giving a probability of about 1.4%.
There are also problems that involve ordinary dice, as used for example in
games like Monopoly. These have six faces, with the numbers 1 through 6
on them. Dice can be biased, so that one face is more likely to show than
another. If we roll an ordinary, unbiased die, what is the probability of rolling
a 5? The six possibilities are equally likely, so the answer is 61 . If the die were
biased, you might try rolling a few hundred times and keeping records.
There are also other dice, with 4, 8, 12 and 20 sides. Usually the die is a
regular polyhedron, and each side contains one number; an n-sided die has
each of 1, 2, . . . , n once.
We say an event is random if you cannot predict its outcome precisely.
This does not mean the chances of different outcomes are equal, although
sometimes people use the word that way in everyday English. For example, if
a die is painted black on five sides, white on one, then the chance of black is 65
48 Introduction to Combinatorics
and the chance of white is 16 . This is random, although the two probabilities
are not equal.
When we talk about the outcomes of a random phenomenon, we mean the
distinct possible results; in other words, no more than one of them can occur,
and one must occur. The set of all possible outcomes is called the sample
space. Each different outcome will have a probability. These probabilities
follow the following rules:
1. One and only one of the outcomes will occur.
2. Outcome X has a probability, P (X), and 0 ≤ P (X) ≤ 1.
3. The sum of the P (X), for all outcomes X, is 1.
P (1) = 0.2, so the probabilities of the other five rolls must add to 0.8. They
are equal, so P (2) = P (3) = P (4) = P (5) = P (6) = 0.16. So the probability
of an even roll is 0.16 + 0.16 + 0.16 = 0.48.
Example 3.5: Walter and John roll a die. If the result is a 1 or 6, John
wins $2 from Walter; otherwise Walter wins $1 from John. What is the event
“John wins”? What is the event “Walter wins”?
We defined the event in a die roll, above to be the set of results that produce
the event. So the event “John wins” is {1, 6}, and the event “Walter wins” is
{2, 3, 4, 5}.
The elementary enumeration methods from Chapter 2 will come in handy
when computing probabilities. For example, if event 1 has x possible out-
comes, event 2 has y possible outcomes, and the two events are not related,
then the compound event “event 1 followed by event 2” has xy possible out-
comes. For example, “roll a die, look at score, roll again” has 6 × 6 = 36
outcomes. If an act has n possible outcomes, then carrying it out k times in
succession, independently, has nk possible outcomes.
One convenient way to represent this sort of situation is a tree diagram.
H
H H T
T T H
T
(a) (b)
FIGURE 3.1: Tree diagrams for coin tossing.
Consider the experiment where a coin is tossed; the possible outcomes are
“heads” and “tails” (H and T ). The possible outcomes can be shown in a
diagram like the one in Figure 3.1(a). A special point (called a vertex ) is drawn
to represent the start of the experiment, and lines are drawn from it to further
vertices representing the outcomes, which are called the first generation. If
the experiment has two or more stages, the second stage is drawn onto the
outcome vertex of the first stage, and all these form the second generation,
and so on. The result is called a tree diagram. Figure 3.1(b) shows the tree
diagram for an experiment where a coin is tossed twice.
Example 3.6: A coin is flipped three times; each time the result is written
down. What is the sample space? Draw a tree diagram for the experiment.
The sample space is
{HHH, HHT, HT H, HT T, T HH, T HT, T T H, T T T }.
50 Introduction to Combinatorics
H
H T
H
T
H T H
T H T H
H
T T H
T H T
T
(a) (b)
FIGURE 3.2: Tree diagrams for Examples 3.6 and 3.7.
The language of events is different from the language of sets in a few cases.
If S is the sample space, then the events S and ∅ are called “certain” and
“impossible,” respectively. If U and V have empty intersection, they are
disjoint sets, but we call them mutually exclusive events (to be consistent
with ordinary English usage).
Example 3.9: A die is thrown. Represent the following events in a Venn
diagram:
A: An odd number is thrown;
B: A number less than 5 is thrown;
C: A number divisible by 3 is thrown.
A
5
1
3
2
6
4
B C
A = {HHT, HT H, T HH, T T T },
B = {HHH, HT T, T HT, T T H},
C = {HHH, HHT, HT H, HT T },
A∪C = {HHH, HHT, HT H, HT T, T HH, T T T },
B ∩C = {HHH, HT T },
C = {T HH, T HT, T T H, T T T }.
A and B are mutually exclusive, as are A and B ∩ C. B ∩ C consists of all
outcomes with a head first and the other two results equal.
Suppose all the different outcomes are equally likely. Say S is the sample
space, and E is the set of all outcomes which we can describe as saying a
certain event happens.
For example, rolling a die, say the event is “score 5 or more.” Then
S = {1, 2, 3, 4, 5, 6}
E = {5, 6}
52 Introduction to Combinatorics
and
|E|
P (event happens) = .
|S|
So, in our example, the probability equals 2/6 or 1/3.
Birthday Probabilities
Suppose there are 30 people in a room. What is the probability that two
of them share the same birthday (day and month)? (To keep the arithmetic
simple, we shall ignore leap years. The probabilities are very similar.) Most
people would say at first that the probability is small, but this is wrong.
First, list the birthdays of the 30 people in the order of their names (al-
phabetical order). If there is no restriction, each person has 365 possible
birthdays. So there are 36530 possibilities.
Suppose no two of them have the same birthday. There are 365 choices for
the first person’s birthday, 364 for the second, 363 for the third, and so on.
With no repeats the total number of possible lists of birthdays is
Therefore the probability of the event “no two have the same birthday” is
365 × 364 × . . . × 336
36530
which is approximately .294. So the probability of the “birthday coincidence”
is about
1 − .294 = .706,
or approximately 70%.
The Game Show
This example was made popular by columnist Marilyn vos Savant.
Consider a TV game show: the contestant chooses between three doors
marked doors 1, 2, 3. Behind one door is a new car; behind each of the other
doors is something almost worthless (a week’s supply of Kleenex tissues; two
movie tickets; a pet goat); call it a booby prize. The contestant chooses a
door, and she gets the prize behind it.
After the choice is announced but before the door is opened, the host opens
one of the other two doors (not the one the contestant chose). Behind the
Probability 53
door we see a goat. The host then asks, “Do you want to stay with your
original choice? Or would you rather switch to the third door?”
Well, should the contestant stay or switch? Or doesn’t it matter? Most
people would say it doesn’t matter.
To analyze the problem, we need to agree that the host always acts the
same way; he always opens a door to show a goat, then offers the switch. And
on any given night the chance that the car is behind any particular door is
one in three. Moreover, we assume that when the contestant’s first choice is
the door with the car, there is an equal chance that the host will open either
of the other two doors; he doesn’t open the lower-numbered one more often,
or anything like that.
Suppose the doors are numbered 1, 2, and 3. The contestant chooses door
1. We shall write C1 to mean “the car is behind door 1,” C2 for “car behind
door 2” and C3 for “car behind door 3.” Similarly, H2 means “host opens
door 2,” and H3 means “host opens door 3”. (He will not ever open door 1.)
Now suppose the game is played 300 times. We expect the car to be behind
each door in 100 cases. If the car is behind door 1, then we expect the host
will open door 2 in 50 cases and open door 3 in 50 cases. In the 100 cases
where the car is behind door 2, he always opens door 3; in the 100 cases where
the car is behind door 3, he always opens door 2. So we can represent the
data by
C1 C2 C3
H2 50 0 100 .
H3 50 100 0
Now suppose the host opens door 2. This tells us that tonight is one of the
150 cases represented in the row H2. Of those 150 cases, the car is behind
door 1 in 50 cases and behind door 3 in 100 cases. So the odds in favor of
switching are 2 to 1. The same reasoning applies when he opens door 3. So
it is always best to switch.
This problem is based on the game “ Let’s Make a Deal,” with host Monty
Hall, so it is often called the Monty Hall problem. Mr Hall has pointed out
that in the real world, the conditions 1 through 4 do not always apply.
Another Game Show
This example was also published by Marilyn vos Savant. We shall call it
the “three marble problem.”
In this game there are three contestants, Alice, Bruce, and Cathy. The host
produces a bag containing three marbles, colored red, blue and yellow. The
host draws one, then puts it back in the bag. Then the contestants each draw
one at random: Alice first, then Bruce, then Cathy. If the marble drawn is
the same color as one that has already been drawn, that contestant wins, and
the contest is over. Otherwise the marble is replaced and the next candidate
draws. The question is, who has the best chance of winning?
The easiest way to analyze this is to ask what would happen if the game is
played N times. Obviously, Alice has probability 31 of drawing the same color
54 Introduction to Combinatorics
as the host, so she will expect to win in 13 N games. In the remaining games,
Bruce draws. There are now two colors that have been drawn, and if Bruce
duplicates either, he wins. He expects to draw in 32 N games, and the chance
of him winning in those cases is 23 , so the expected number of wins is 23 × 23 N .
So his probability is 49 . If he loses, then all three colors have been drawn, so
Cathy wins in all the remaining cases, and her probability is 1 − 13 − 49 = 92 .
Therefore, Bruce has the best chance of winning.
1 1
P (1) = 6 P (2) = 6
1 1
P (3) = 6 P (4) = 6 .
1 1
P (5) = 6 P (6) = 6
This is still a good probability model, because the probabilities still add to
1.
In some cases there is no numerical value associated with the outcomes.
However, in many probability models, each outcome is a number, or has a
numerical value. For example, this is true of rolling dice.
For example, suppose you are playing a game with three outcomes, call
them A, B, C. If the outcome is A, you win $10. If it is B, you win $2. And
if it is C, you lose $15. The game is completely random, and observations
show that A and C each occur 40% of the time, while B is the result of 20%
of plays.
If the game were played 100 times, your best guess would be that A came
up 40 times, B 20 and C 40. So someone who played 100 times might expect
to win $(10 × 40 + 2 × 20), or $440, and lose $15 × 40 = $600. The net loss is
$160, or $1.60 per play. You would say this is the expected cost of a play.
In general, suppose an occurrence has a numerical value associated with
outcome, and a probability also. The expected value of the occurrence is
found by multiplying each value by the associated probability, and adding.
Probability 55
This is also called the mean value, or mean of the occurrence. The mean is
most commonly denoted m.
Example 3.11: You are playing a game where you draw cards from a
standard deck. If you draw a 2, 3, . . . , or 10, you score 1 point; a jack, queen
or king is worth 3; and an ace is 5 points. How many points would you get
for a typical draw?
The probability of a draw worth 1 point is 36/52, or 9/13, since 36 of the
52 cards are worth 1 point, Similarly, the probabilities of values 3 and 5 are
3/13 and 1/13 respectively. So the expected value is
9 3 1
×1+ ×3+ × 5 = 23/13.
13 13 13
Similar calculations can be applied to any probability model where the
outcomes have values associated with them.
Example 3.12: Suppose a fair coin is tossed four times. What is the
probability that a head occurs exactly twice?
Assume that a head counts as a success. From the formula, with p = q = .5,
n = 4 and k = 2, the probability is
n k n−k 4 1 3
P (k) = p q = 0.52 × 0.52 = 6 × 4 = .
k 2 2 8
In poker, the hands on the above list always beat the hands lower than them.
This same ranking is used in all variations of poker.
Another form of poker involves wild cards. The simplest model is where
one additional card, a joker, is added to the deck. A player who receives the
joker can say it is any card she wishes. A card whose meaning can be decided
by the player is called a wild card. There are other models—for example, all
the twos are wild cards, or there are two or more jokers. But we will restrict
ourselves to the one-joker case.
With a 53-card deck, there are 2,869,685 possible hands. We assume that,
if a hand has a joker, the joker is assigned the value that makes the hand
the strongest. For example, given three kings, a four and a joker, the joker
would be a king, and the hand would be a four of a kind. The suit only needs
to be specified when a flush or straight flush is involved. There is one new
type of hand possible, a five of a kind, and it outranks all the other hands.
The numbers of hands of the various types, and their probabilities, are easily
calculated:
58 Introduction to Combinatorics
Exercises 3A
1. If the probability that it will rain today is 0.74, what is the probability
that it will not rain?
2. A box contains eight marbles: five red, two blue and one white. One is
selected at random. What is the probability that:
(i) The marble is blue;
(ii) The marble is not blue?
3. Two dice are rolled and the numbers showing are added. What is the
probability that the sum is greater than nine?
Probability 59
5. A coin is tossed. If the first toss is a head, the experiment stops. Oth-
erwise, the coin is tossed a second time.
(i) Draw a tree diagram for this experiment.
(ii) List the members of the sample space.
(iii) Assume the coin is fair, so that there is a probability 12 of tossing
a head. What is the probability of the event, “the coin is tossed
twice”?
6. A fair coin is tossed four times. What is the probability that it lands
heads exactly once?
7. We roll two fair six-sided dice and wish to roll doubles, that is, to have
the same number appear on each die. What is the probability of this in
a given roll?
8. The word “SLEEP” is printed on five cards, one letter on each card. The
cards are shuffled and laid out in random order. What is the probability
that the rearrangement will contain the word “EEL” in order from left
to right with no letters intervening (for example, PEELS or SPEEL)?
What is the probability that “LEP” occurs in the same way?
9. Suppose a four-sided die and a six-sided die are rolled together, and the
total is calculated. What are the possible values of the total? Assuming
the dice are fair, what are the probabilities of the different totals?
12. Electronic components are being inspected. Initially one is selected from
a batch and tested. If it fails, the batch is rejected. Otherwise a second
is selected and tested. If the second fails, the batch is rejected; otherwise
a third is selected. If all three pass the test, the batch is accepted.
(i) Draw a tree diagram for this experiment.
(ii) How many outcomes are there in the sample space?
(iii) What is the event, “fewer than three components are tested”?
Exercises 3B
1. Exactly one of three contestants will win a game show. The probability
that Joseph wins is 0.25 and the probability that Alice wins is 0.4. What
is the probability that Barbara wins?
3. Two fair dice are rolled. What are the probabilities of the following
events?
(i) The total is 7;
(ii) The total is even;
(iii) Both numbers shown are even.
4. The word “TOAST” is printed on five cards, one letter on each card.
The cards are shuffled and laid out in a line, in random order. What is
the probability that the rearrangement will contain the word “TOT” in
order from left to right with no letters intervening (for example, TOTAS
or STOTA)? What is the probability that “ATO” occurs in the same
way?
6. A bag contains two red, two green and three blue balls. In an experi-
ment, one ball is drawn from the bag and its color is noted, and then a
second ball is drawn and its color noted.
(i) Draw a tree diagram for this experiment.
(ii) How many outcomes are there in the sample space?
(iii) What are the outcomes in the event, “two balls of the same color
are selected”?
7. A die is rolled twice, and the results are recorded as an ordered pair.
(i) How many outcomes are there in the sample space?
(ii) Consider the events:
E : The sum of the throws is 4;
F : Both throws are even;
G : The first throw was 3.
(a) List the members of events E, F and G.
(b) Are any two of the events E, F, G mutually exclusive?
(iii) Draw a tree diagram for this experiment.
(iv) Represent the outcomes of this experiment in a Venn diagram.
Show the events E, F and G in the diagram.
(v) Assuming the die is unbiased, what are the probabilities of E, F
and G?
8. A card is drawn from a standard deck of cards, and then replaced. Then
another card is drawn.
(i) What is the probability that both are red?
(ii) What is the probability that neither is red?
Number in line 0 1 2 3 4 5
Probability 0.08 0.15 0.20 0.22 0.15 0.20
Problems
Problem 4: In the three marble problem, suppose four different marbles are
used instead of three. Which player has the best chance of winning? Assuming
that each player draws a marble only once, what is the probability that there
is no winner?
Problem 5: Suppose three regular, six-sided dice are rolled, and the two
highest numbers shown are added. What is the probability that this sum is
9? What is the expected value of the sum?
Problem 6: Suppose we roll two fair six-sided dice and wish to roll doubles,
as in Exercise 3A.6.
(i) What is the probability of not getting doubles in one roll? In two
consecutive rolls? In three consecutive rolls?
(ii) What is the probability of getting doubles two or more times in six
attempts?
Problem 8: Show that if event E1 has expected value v1 , and E2 has v2 , then
the random event consisting of adding the values of E1 and E2 has expected
value v1 + v2 . Use this result to find the expected value obtained by rolling n
fair k-sided dice when each die has faces numbered 1 through k, and adding
the numbers showing on the upper faces.
Problem 9: Consider all the subsets with four elements of the set {0, 1, . . . , 9}.
The sum of such a set is the sum of the four elements. Without calculating
all the sums or listing all the subsets, show that there must be at least 10
subsets with the same sum.
Chapter 4
The Pigeonhole Principle and
Ramsey’s Theorem
65
66 Introduction to Combinatorics
We can also see that form (ii) of the principle can be used to deduce (i).
Let ai = |Si |. Then by (4.1) we have
n
X
|S| = ai > n + 1;
i=1
Example 4.3: [62] Choose an integer n. Show that there exists an integer
multiple of n that contains only the digits 0 and 1 (in the usual decimal
notation).
The Pigeonhole Principle and Ramsey’s Theorem 67
i
Consider the integers mi = 10 9−1 , for 1 ≤ i ≤ n. For every i, mi is
represented in the decimal scale by a string of i ones. We look at their
residues modulo n: if some mi is divisible by n, the problem is solved; if not,
then the n integers m1 , m2 , . . . , mn must belong to the (n − 1) residue classes
congruent to 1, 2, . . . , n − 1(mod n), so for some i and j, 1 ≤ i < j ≤ n,
mi ≡ mj (mod n).
with at most four elements. The lower bound on the sums of the non-empty
subsets is obviously 1; the upper bound on the sums of the k-sets, for k ≤ 4,
is 21 + 22 + 23 + 24 = 90. Since we have 98 sums that can take at most 90
values, at least two sums must be equal.
Example 4.7: [76] A student solves at least one problem every day. Since
she is anxious not to overwork she makes it a rule never to solve more than
730 problems per year. Show that she solves exactly n problems in some set
of consecutive whole days for any given positive integer n.
Consider first the case where n = 1; this gives us a clue to the solution.
Suppose that the student solves exactly two problems per day, throughout any
year with 365 days. She thus solves 730 problems in the whole year and on no
one day has she solved exactly one problem. But during a leap year, solving
exactly two problems per day leads her to exceed her quota: there are at least
two days of a leap year on each of which she must solve exactly one problem.
Since leap years include all those with numbers divisible by 4 but not by 25
(as well as those with numbers divisible by 400), any eight consecutive years
include at least one leap year and contain at least (8 × 365) + 1 = 2921 days.
We start from some fixed date and let Si be the number of problems solved
in the first i days from the starting date. Consider the sets of integers
S = {Si : 1, ≤ i ≤ N = 2921n}
and
T = {n + Si : 1, ≤ i ≤ N = 2921n}.
Notice that Si 6= Sj when i 6= j, since the student solves at least one problem
per day. Similarly n + Si 6= n + Sj when i 6= j. Now
|S| + |T | = 2N = 5842n;
all the elements of S and T are positive integers, the largest of which is n + S,
and
n + Sn ≤ n + (8n × 730) = 5841n.
Hence, there exists at least one positive integer j belonging to both S and T .
So for some h and k,
j = Sh = n + Sk ,
which means that on the days k + 1, k + 2, . . . , h, the student solved exactly
n problems.
The Pigeonhole Principle and Ramsey’s Theorem 69
LEMMA 4.2
There exists a number R(p, q) such that any coloring of KR(p,q) in two colors
c1 and c2 must contain either a Kp with all its edges in color c1 or a Kq with
all its edges in c2 .
The same argument can be used when there are more than two colors. The
general result is the graphical version of a result called Ramsey’s Theorem.
R(p1 , p2 , . . . , pn )
G G
On the other hand, K8 can be colored with no red K3 or blue K4 . The graph
G of Figure 4.2 has no triangle, and can be taken as the red monochromatic
subgraph, while its complement G is the blue graph. (The construction of
this graph will be discussed in Section 4.5, below.) So R(3, 4) = 9.
72 Introduction to Combinatorics
Proof. Suppose Kv is colored in two colors, red and blue. Write R for the
number of red triangles, B for the number of blue triangles, and P for the
number of partial triangles—triangles with at least one edge of each color.
There are n3 triangles in Kv , so
v
R+B+P = .
3
The triangle xyz can be considered as the union of the three paths xyz,
yzx and zxy. Moreover, the paths corresponding to different triangles will all
be different. If the triangle is monochromatic, no path is mixed, but a partial
The Pigeonhole Principle and Ramsey’s Theorem 73
triangle gives rise to two mixed paths. So there are 2P mixed paths in the
Kv , and
v
1X
P = ri (v − 1 − ri ).
2 i=1
If v is odd, the maximum value of ri (v − 1 − ri ) is (v − 1)2 /4, attained when
ri = (v − 1)/2. If v is even, the maximum of v(v − 2)/4 is given by ri = v/2
or (v − 2)/2. In either case, the maximum is
2
v−1
,
2
so
2
1
Pv v−1
P ≤ 2 L=1 2
v v−1
≤ 2 2 12 ,
This theorem provides the upper bounds 2 and 5 for N2,6 (3) and N3,17 (3),
both of which can be met [47, 96, 120].
a + b = c;
x − y + y − z = x − z,
COROLLARY 4.6.1
If there exists a sum-free partition of an n-element group into k parts, then
Rk (3) > n.
For example, the partition
provides the well-known partition of Z5 into two 5-cycles that is used in prov-
ing that R2 (3) = 6. The partition
xy + zt = (x + z)(y + t)
(Z4 × Z4 )∗ = R ∪ B ∪ G
where
(in each case, xij will be either i − j or j − i). But a complete search shows
that B contains no solution to these equations. So the graph contains no K4 .
(The graph is G in Figure 4.2.)
LEMMA 4.7
If p and q are integers greater than 2, then
Hence the given bound is valid for n = 4. Also for any value of q, R(2,
q) =
q = 2+q−2 p+2−2
2−1 , and similarly for any value of p, R(p, 2) = p = p−1 , so the
bound is valid if p = 2 or q = 2.
Without loss of generality assume that p ≥ 3, q ≥ 3 and that
′
p + q′ − 2
′ ′
R(p , q ) ≤
p′ − 1
and to p′ = p, q ′ = q − 1, obtaining
p+q−3
R(p, q − 1) ≤ .
p−1
But by the properties of binomial coefficients,
p+q−3 p+q−3 p+q−2
+ = ,
p−2 p−1 p−1
and from Lemma 4.7
so
p+q−3 p+q−3 p+q−2
R(p, q) ≤ + = .
p−2 p−1 p−1
q2 + q
q + 1 q(q + 1)
R(3, q) ≤ = .
2 2 2
But for the case p = 3, this result can be improved. It may be shown that
for every integer q ≥ 2,
q2 + 3
R(3, q) ≤ .
2
The following lower bound for Rn (k) was proved by Abbott [1].
The Pigeonhole Principle and Ramsey’s Theorem 79
(i) There are s distinct values of i for which the vertex wij belongs to G.
Then from the coloring scheme Kp contains a monochromatic Ks , which
is a contradiction;
(ii) There are at most s − 1 distinct values of i for which wij belongs to G.
Suppose there are at most t− 1 distinct values of j such that wij belongs
to G. Then G has at most (s − 1)(t − 1) = st − s − t + 1 = r − 1 vertices,
which is a contradiction. So there is at least one value of i such that at
least t of the vertices wij belong to G. Applying the argument of case
(i), Kq contains a monochromatic Kt , which is again a contradiction.
LEMMA 4.10
For any positive integer n
f (n + 1) ≥ 3f (n) + 1,
and since f (1) = 1,
3n − 1
f (n) ≥ .
2
Proof. Suppose that the set S = {1, 2, . . . , f (n)} can be partitioned into
the n sum-free sets S1 = {x11 , x12 , . . . , x1ℓ1 }, . . . , Sn = {xn1 , xn2 , . . . , xnℓn }.
Then the sets
T1 = {x11 , 3x11 − 1, 3x12 , 3x12 − 1, . . . , 3x1ℓ1 , 3x1ℓ1 − 1},
T2 = {x21 , 3x21 − 1, 3x22 , 3x22 − 1, . . . , 3x2ℓ1 , 3x2ℓ1 − 1},
...
Tn = {3xn1 , 3xn1 − 1, 3xn2 , 3xn2 − 1, . . . , 3xnℓn , 3xnℓn − 1},
Tn+1 = {1, 4, 7, . . . , 3f (n) + 1}
form a partition of {1, 2, . . . , 3f (n) + 1} into n + 1 sum-free sets. So
f (n + 1) ≥ 3f (n) + 1.
Now f (1) = 1, so the above equation implies that
3n − 1
f (n) ≥ 1 + 3 + 32 + · · · + 3n−1 = .
2
Proof. (i) The proof of the upper bound is a generalization of the method
used to establish R3 (3) ≤ 17.
(ii) Let Kf (n)+1 be the complete graph on the f (n) + 1 vertices x0 , x1 , . . . ,
xf (n) . Color the edges of Kf (n)+1 in n colors by coloring xi xj in the kth color
if and only if |i − j| ∈ Sk .
Suppose the graph contains a monochromatic triangle. This must have
vertices xa , xb , xc with a.b.c, such that a − b, b − c, a − c ∈ Sk . But now
(a − b) + (b − c) = a − c, contradicting the fact that Sk is sum-free. Hence
f (n) + 1 ≤ Rn (3) − 1,
so that
3n − 1 3n − 3
+2= ≤ Rn (3),
2 2
which proves the lower bound.
The Pigeonhole Principle and Ramsey’s Theorem 81
Πr (S) = A1 ∪ A2 ∪ · · · ∪ An
R(p1 , p2 , . . . , pn ; r),
Exercises 4A
1. How many times must we throw a die in order to be sure that we get
the same score at least twice?
3. A night club’s patron parking lot contains 25 cars, and there are 101
patrons in the night club. Assume all of the patrons arrived by car; find
the greatest number k such that some car must have contained at least
k people.
the five-day work week, but no more than eight tax returns in any calen-
dar week. Show that there is some set of consecutive work days during
which she completes exactly 19 tax returns.
5. A student in an English class is expected to turn in journal entries.
The class meets four times a week, and the student wants to turn in
at least one journal entry per class day, but no more than six journal
entries during a calendar week for the entire 15-week semester. Show
that there exists some sequence of consecutive days during which the
student turns in exactly 29 journal entries.
6. Let S = {1, 2, . . . , n}, let r be an integer not belonging to S and let
T = S ∪ {r}. Show that there exists x ∈ S such that the sum of all the
elements of T \{x} is divisible by n.
7. Let p be a prime, p 6= 2, p 6= 5. Show that there exists a positive power
of p which, written in the decimal system, ends . . . 01.
8. Let x be any positive real number and let n be any positive integer.
Show that there exist positive integers h and k such that
1 1
h− ≤ kx ≤ h + .
n n
(That is, show that some integral multiple of x is arbitrarily close to an
integer.)
9. What is the relation between R(p1 , p2 , p3 , . . . , pn ; r) and R(p2 , p1 , p3 , . . . ,
pn ; r)?
10. Prove that R(3, 5) ≤ 14.
11. Prove that R(3, 5) > 13 by choosing R = {4, 6, 7, 9}, B = {1, 2, 3, 5, 8, 10,
11, 12} in Z13 . (Note: Together with the preceding exercise, this proves
that R(3, 5) = 14.)
12. Verify that the partition in (4.2) is in fact a symmetric sum-free parti-
tion.
13. Is it possible to 2-color the edges of K35 so that no red K4 or blue K5
occurs?
Exercises 4B
1. How many times must we throw two dice in order to be sure that we
get the same total score at least six times?
The Pigeonhole Principle and Ramsey’s Theorem 83
2. Let n and B be given positive integers. Show that there exists an integer
divisible by n that contains only the digits 0 and 1 when it is written in
base B.
R(2, q) = q, R(p, 2) = p.
10. Prove that any edge-coloring of K7 in two colors must contain at least
three monochromatic triangles.
12. Suppose there exists a painting of K17 in the three colors red, blue and
green that contains two or fewer monochromatic triangles. If v is any
vertex, write R(v), B(v) and G(v) for the sets of vertices joined to v by
red, blue and green edges respectively, and write r(v) = |R(v)|, and so
on.
(i) Select a vertex x that lies in no monochromatic triangle. Prove
that one of {r(x), b(x), g(x)} is equal to 6 and the other two each
equal 5.
84 Introduction to Combinatorics
(ii) Without loss of generality, say r(x) = 6. Let S be the set of all
vertices of K17 that lie in monochromatic triangles. Prove that
S ⊆ R(x).
(iii) If y is any member of B(x), it is clear that S lies completely within
R(y), B(y) or G(y). Prove that, in fact, S ⊆ R(y).
(iv) Prove that there must exist two vertices y1 and y2 in B(x) such
that y1 y2 is red.
(v) Use the fact that S ⊆ R(y1 ) ∩ R(y2 ) to prove that K17 contains
more than two red triangles. So N3,17 (3) ≥ 3.
13. Verify that the partition in (4.3) is in fact a symmetric sum-free parti-
tion.
14. Show that R(4, 4) > 17, by choosing
in Z17 . (Note: Together with Exercise 11, this proves that R(4, 4) = 18.)
15. Is it possible to 2-color the edges of K25 so that no monochromatic K5
occurs?
Problems
Problem 1:
(i) Let S be an s-set, where s > nm. Show that if S is partitioned into n
subsets, then at least one of the subsets contains more than m elements.
Pn
(ii) Let a1 , a2 , . . . , an be real numbers such that i=1 ai > b. Show that for
at least one value of i, i = 1, . . . , n, ai ≥ b/n.
Pn
(iii) Let a1 , a2 , . . . , an be real numbers such that i=1 ai ≤ b. Show that for
at least one value of i, i = 1, . . . , n, ai ≤ b/n.
Pn
(iv) Let a1 , a2 , . . . , an be real numbers such that i=1 ai < b. Show that for
at least one value of i, i = 1, . . . , n, ai < b/n.
Problem 2: Suppose N objects are distributed between B boxes in such a
way that no box is empty. How many objects must we choose in order to be
sure that we have chosen the entire contents of at least one box?
Problem 3: There are 12 signs of the (Western) Zodiac, corresponding
roughly to which month a person is born in. Similarly, there are twelve ani-
mal signs of the so-called “Chinese Zodiac,” (Rat, Ox, Tiger, Rabbit, Dragon,
Snake, Horse, Goat, Monkey, Rooster, Dog, and Boar) corresponding roughly
The Pigeonhole Principle and Ramsey’s Theorem 85
to which year a person is born in. Suppose there are 145 people in a room.
Show that:
(i) There must be 13 people who share the same sign of the Western Zodiac;
(ii) There must be 13 people who share the same sign of the Chinese Zodiac;
(iii) There must be at least two people who have the same sign in both
Zodiacs.
Problem 4: Let p be a given prime and let R0 , R1 , . . . , Rp−1 be the residue
classes modulo p. Let A = {a1 , a2 , . . . , an } be a set of integers, and define a
partition of A into sets A0 , A1 , . . . , Ap−1 by
Ai = {ai1 , ai2 , . . . , aiki } = A ∩ Ri , 0 ≤ i ≤ p − 1.
|X ∪ Y | = |X| + |Y | − |X ∩ Y |. (5.1)
A Venn diagram illustrating this equation is shown in Figure 5.1. To enu-
merate X ∪ Y , first count all elements in the shaded areas and then subtract
the number of elements in the heavily shaded area.
X Y
If X is the collection of all the objects of type I in some universal set and
Y consists of all objects of type II, then (5.1) expresses the way to count the
objects that are either of type I or type II:
(i) count the objects of type I;
(ii) count the objects of type II;
87
88 Introduction to Combinatorics
X Y X Y
|Y | + |Z| − |Y ∩ Z|;
|X ∩ Y | + |X ∩ Z| − |X ∩ Y ∩ Z|.
|X ∪ Y ∪ Z| = |X| + |Y | + |Z|
−|X ∩ Y | − |Y ∩ X| − |X ∩ Z|
+|X ∩ Y ∩ Z|.
|X1 ∪ X2 ∪ · · · ∪ Xn |
Xn n
X Xn
= |Xi1 | − |Xi1 ∩ Xi2 | + · · ·
i1 =1 i1 =1 i2 =i1 +1
n
X X n n
X (5.4)
k−1
+(−1) ··· |Xi1 ∩ Xi2 ∩ · · · ∩ Xik |
i1 =1 i2 =i1 +1 ik =ik−1 +1
+···+ (−1)n−1 |Xi1 ∩ Xi2 ∩ · · · ∩ Xin |.
90 Introduction to Combinatorics
Xi1 ∩ Xi2 , since it appears in precisely those for which {il , i2 } is a 2-set of
{jl , j2 , . . . , jr }; so it contributes − 2r to that part of (5.4). Continuing, we
obtain total contribution
r
X r
(−1)k−1 , (5.5)
k
k=1
which equals 1 by Corollary 2.3.3 (see Exercise 2A.14). So (5.4) counts 1 for
every member of X1 ∪ X2 ∪ · · · ∪ Xn ; therefore its total is |X1 ∪ X2 ∪ · · · ∪ Xn |.
Example 5.2: The Red Hat licorice makers, following the success of their
first contest, introduce “Red Hat 21,” a casino-type game played with licorice
hats. Again, they run a promotion; this time, the tickets are anagrams of
REDHAT21, and the winning tickets must either contain RED or HAT or 21.
For example, RH21EDTA and HA2RED1A are winners. How many winners
are there this time? What percentage of tickets are winners?
We proceed as we did in Example 5.1, but this time we count three sets, R,
H and T (for “twenty-one”). The anagrams containing RED are equivalent
to ways of organizing the six symbols H, A, T, 2, 1 and RED, so |R| = 6!.
Similarly H, the set of those containing “HAT,” has 6! elements and T has
7! elements. The intersections are counted similarly: R ∩ H, has 4! elements
(RED, HAT, 2 and 1) while |R ∩ T | = |H ∩ T | = 5!. Finally, there are 3!
elements in R ∩ H ∩ T , corresponding to the 3! ways of ordering the three
words RED, HAT and 21. From (5.4), the number of elements of R ∪ H ∪ T
is
So there are 6,222 winners. There are 8! = 40320 tickets, so about 15.4% are
winners.
All
All
All
Suppose we want to know how many of the positive integers smaller than
n are perfect squares, perfect cubes, or perfect higher powers. As an example
we shall find out how many of the positive integers less than 200 are perfect
powers higher than the first. Trivially, 1 is a perfect kth power for every k,
so we omit 1 from our calculations, and add 1 to the answer. In this case we
need only consider up to seventh powers: 28 = 256 > 200, so every eighth or
higher power of x is greater than 200 whenever x ≥ 2. For i = 2, 3, . . . , 6 let
us write Pk for the set of all kth powers of integers that lie between 2 and 199
(inclusive). Then, from (5.4), the number of integers that belong to at least
one of these sets is
|P2 | + |P3 | + |P4 | + |P5 | + |P6 | + |P7 |
− (|P2 ∩ P3 | + |P2 ∩ P4 | + . . . + |P5 ∩ P7 | + |P6 ∩ P7 |)
+ (|P2 ∩ P3 ∩ P4 | + |P2 ∩ P3 ∩ P5 | + . . . + |P5 ∩ P6 ∩ P7 |)
− (|P2 ∩ P3 ∩ P4 ∩ P5 | + . . . + |P4 ∩ P5 ∩ P6 |)
+ (|P2 ∩ P3 ∩ P4 ∩ P5 ∩ P6 | + . . . + |P3 ∩ P4 ∩ P5 ∩ P6 ∩ P7 |)
− |P2 ∩ P3 ∩ P4 ∩ P5 ∩ P6 ∩ P7 |.
All of these sets and their sizes are easy to calculate. The largest square up
to 199 is 142 , so P2 = {2, 3, 4, . . . , 14} and |P2 | = 13, P3 = {2, 3, 4, 5} so
|P3 | = 4, |P4 | = 3, |P5 | = |P6 | = |P7 | = 1. If k > 7 then Pk is empty. In
general Pi ∩ Pj = Pl , where l is the least common multiple of i and j, and
similarly for intersections of three or more, so P2 ∩ P3 = P2 ∩ P6 = P3 ∩ P6 =
P2 ∩ P3 ∩ P4 = P2 ∩ P3 ∩ P6 = P6 , P2 ∩ P4 = P4 , and all the others are empty.
Therefore the total is
|P2 | + |P3 | + |P4 | + |P5 | + |P6 | + |P7 |
− |P2 ∩ P3 | − |P2 ∩ P4 | − |P2 ∩ P6 | − |P3 ∩ P6 |
+ |P2 ∩ P3 ∩ P4 | + |P2 ∩ P3 ∩ P6 |
which equals 13 + 4 + 3 + 1 + 1 + 1 − 1 − 3 − 1 − 1 + 1 + 1 = 19. So the answer
to the original question is 20 (adding 1 for the integer 1).
In some applications of Inclusion/Exclusion, all the sets Xi are the same
size, as are all the intersections of two sets (like Xi1 ∩Xi2 ), all the intersections
of three sets, and so on. If the intersection of any k of the sets Xi always has
sk elements, then (5.4) becomes
n n
ns1 − s2 + s3 − · · · + (−1)n−1 sn . (5.7)
2 3
This is called the uniform form of the Principle of Inclusion and Exclusion.
Example 5.4: A bank routing number is a string of nine digits. For
the purposes of this example, let us assume that any digit can be used in
any position, so that there are 109 possible routing numbers (the number of
sequences length 9 on 10 symbols). How many routing numbers contain all
the odd digits?
The Principle of Inclusion and Exclusion 93
To calculate how many routing numbers contain all the odd digits, we find
out how many do not contain all the odd digits, then subtract that number
from 109 . Write Rx for the set of all routing numbers that do not contain x.
Then we want to calculate |R1 ∪ R3 ∪ R5 ∪ R7 ∪ R9 |. For any x, the number of
routing numbers not containing x equals the number of sequences of length 9
on 9 symbols, so |Rx | = 99 ; similarly, if x 6= y then |Rx ∩ Ry | = 89 ; if x, y, z
are all different then |Rx ∩ Ry ∩ Rz | = 79 , and so on. So, from (5.7), the sum
is
9 5 9 5 9 5
5×9 − ×8 + ×7 − × 69 + 59
2 3 4
and the answer we require is
109 − 5 × 99 + 10 × 89 − 10 × 79 + 5 × 69 − 59 .
Theorem 2.8 tells us that, if any object can be repeated as often as we wish,
the number of ways to choose a collection of size k is
n+k−1 n+k−1 (n + k − 1)!
= = . (5.9)
k n−1 k!(n − 1)!
|X1 ∩ X2 ∩ · · · ∩ Xn |.
433, 424, 415, 406, 334, 325, 316, 235, 226, 136.
The same technique applies when there are infinitely many elements of some
or all types.
The Principle of Inclusion and Exclusion 95
Example 5.6: Solve Example 4.5 when you also have unlimited elements
of type A4 .
Now n = 4, so |X| = 13 8 9
3 = 286, |X1 | = 3 = 56, |X2 | = 3 = 84, |X3 | =
6 4
3 = 20, |X1 ∩X2 | = 3 = 4, and |X1 ∩X3 | = |X2 ∩X3 | = |X1 ∩X2 ∩X3 | = 0.
(As type A4 is unrestricted, there is no set X4 .) So the answer to this new
question is 286 − (56 + 84 + 20) + 4 − 0 = 122. Even in this small case, hand
checking is already tedious.
Example 5.7: How many integer solutions are there to the equation x +
y + z = 14, subject to 3 ≤ x ≤ 7, 1 ≤ y ≤ 4, 0 ≤ z ≤ 6?
5.4 Derangements
A derangement of an ordered set of objects is a way of rearranging the
objects so that none appears in its original position. A derangement of
(1, 2, . . . , n), for example, is an arrangement (x1 , x2 , . . . , xn ) of the first n
integers in which xi = i never occurs. We write Dn for the number of possible
derangements of n objects; clearly Dn does not depend on the type of objects
in the set.
For consistency, we define D0 = 1. The first few values of Dn are easy
to calculate. For example, D1 = 0 (how can you put the members of a 1-
element set in a different order?) and D2 = 1. The six permutations of 123
are 123, 132, 213, 231, 312, 321, and the only derangements are 231 and 312,
so D3 = 2. But there are nine derangements of four objects, and the number
grows rapidly.
One expression for Dn is derived from the Principle of Inclusion and Ex-
clusion.
96 Introduction to Combinatorics
1 1 1 1
Dn = n![1 − + − + · · · + (−1)n ]. (5.10)
1! 2! 3! n!
Example 5.10: Five people attend a party and all check their coats. When
they leave, they are given the wrong coats; no one gets their own coat. If the
coats were returned at random, what is the chance of this happening?
The coats could have been returned in 5! ways. The chance of a derange-
ment is D5 /5! = 44/120 = 11/30, or approximately 37%.
Example 5.11: Five couples, man and woman, attend a party and all
check their coats. When they leave, they are given the wrong coats; each man
is given a man’s coat, but no one gets their own coat. In how many ways can
this happen?
Label the couples 1, 2, 3, 4, 5. Say man i gets the coat belonging to man xi .
Then x1 x2 x3 x4 x5 is a derangement of 12345, so there are D5 ways in which
this can happen. As the men’s coats are all accounted for, each woman gets
a woman’s coat, but the wrong one. So this can also happen in D5 ways. By
the multiplication principle, there are D52 = 442 = 1936 ways.
If we subtract nDn−1 from each side of the result of Theorem 5.3, we obtain
Dn − nDn−1 = −[Dn−1 − (n − 1)Dn−2 ],
provided n ≥ 3. The expression on the right-hand side is derived from the
left-hand side by subtracting 1 from each expression of the variable, and then
negating. Repeating this process, we get
Dn − nDn−1 = (−1)[Dn−1 − (n − 1)Dn−2 ]
= (−1)2 [Dn−2 − (n − 2)Dn−3 ]
= (−1)3 [Dn−3 − (n − 3)Dn−4 ]
= ...
= (−1)n−2 [D2 − 2D1 ].
We know D2 = 1 and D1 = 0. So
Dn − nDn−1 = (−1)n−2 (1 − 0),
or more simply
Dn = nDn−1 + (−1)n . (5.11)
98 Introduction to Combinatorics
Exercises 5A
1. You need to choose a set of four members from {a, b, c, d, e, f, g, h} that
contains either a or b.
(i) In how many ways can this be done?
(ii) In how many ways can it be done if you may not include both a
and b?
2. Find the number of positive integers that are smaller than 200 and are
relatively prime to 21.
3. Find the number of integers between 1 and 5,000 inclusive that are not
divisible by 4, 5 or 6.
4. How many elements are there in the set A ∩ B, if |A| = 28, |B| = 34,
and:
(i) A and B are disjoint?
(ii) |A ∪ B| = 47?
(iii) A ⊆ B?
5. 2,200 voters were surveyed about a new federal building. Of them, 703
were in favor of financing it with a new sales tax, 525 favored a new
property tax, while 336 said they would vote in favor of either measure.
(i) How many favor property tax but not sales tax?
(ii) How many favor sales tax but not property tax?
(iii) How many would vote against either form of funding?
7. Inspired by the makers of Red Hat licorice, the distributors of Red Hat
Linux decide to start a contest. Each contestant receives an anagram
of REDHATLINUX, and is a winner if none of the words RED, HAT,
LINUX appears in its correct order. For example, HLXREDATINU
is not allowed, because of RED. Of the 11! anagrams, how many are
winners?
The Principle of Inclusion and Exclusion 99
x + y + z + t = 18
that satisfy 2 ≤ x ≤ 4, 1 ≤ y ≤ 6, 3 ≤ z ≤ 6, 4 ≤ t ≤ 7.
11. Find the number of integers between 1 and 6,000 inclusive that are
neither perfect squares nor perfect cubes.
12. How many elements are there in the union of the four sets X1 , X2 , X3 , X4
if each of the sets has precisely 16 elements, each intersection Xi ∩ Xj
has precisely eight elements, each triple of sets has exactly one element
in common, and there is no element common to all four sets?
13. Each of the sets X1 , X2 , X3 , X4 has 24 elements. X1 and X3 are disjoint;
every other intersection of two of the sets has 12 elements. |X1 ∩ X2 ∩
X4 | = 7, |X2 ∩ X3 ∩ X4 | = 1. What is the size of X1 ∪ X2 ∪ X3 ∪ X4 ?
14. Calculate D6 , D7 and D8 .
15. Six women at a party check their coats. In how many ways can the
following occur?
(i) No one gets her own coat back.
(ii) Exactly one woman gets her own coat back.
(iii) At least one woman gets her own coat back.
(iv) Every woman but one gets her own coat back.
16. What is the number of permutations of {1, 2, 3, 4, 5, 6, 7} in which ex-
actly three of the integers are in their original position?
Exercises 5B
1. A survey was carried out. It was found that 20 of the people surveyed
followed football on television, while 15 followed baseball; 12 watched
both football and baseball, but 14 watched neither. Use the formula
(5.1) to find out how many people were interviewed.
100 Introduction to Combinatorics
2. Find the number of positive integers that are smaller than 100 and are
relatively prime to 10.
3. Find the number of integers that are not divisible by 4, 5 or 6:
(i) between 1 and 10,000 inclusive;
(ii) between 5,001 and 10,000 inclusive.
4. How many elements are there in the set S ∪ T , if |S| = 14, |T | = 17,
and:
(i) S and T are disjoint?
(ii) |S ∩ T | = 11?
(iii) S ∩ T is empty?
5. A survey was carried out. It was found that 185 of the people surveyed
drank tea regularly, while 344 were coffee drinkers; 126 regularly drank
both beverages, while 84 drank neither. Use formula (5.1) to find out
how many people were interviewed.
6. Find the number of distinguishable 10-subsets of
x + y + z + t = 24
10. A shopping precinct contains Staples, Office Depot and Best Buy stores.
In a survey of 150 shoppers, it is found that
(a) 87 shopped at Office Depot;
(b) 101 shopped at Staples;
(c) 92 shopped at Best Buy;
(d) 72 shopped at both Office Depot and Staples;
(e) 75 shopped at both Staples and Best Buy;
(f) 62 shopped at both Office Depot and Best Buy;
(g) 52 shopped at all three stores.
(i) How many people shopped only at Office Depot?
The Principle of Inclusion and Exclusion 101
(ii) How many people shopped at Office Depot and Staples, but not at
Best Buy?
(iii) How many people shopped at exactly one of the stores?
(iv) How many people shopped at none of the three stores?
11. You have five sets, X1 , X2 , X3 , X4 , X5 , each of size 12. X1 , X3 and X5
are pairwise disjoint; |X − 2 ∩ X4 | = 6; every other intersection of two
of the sets has three elements. What is the size of the following sets:
X1 ∪ X2 ∪ X3 ∪ X4 , X2 ∪ X4 ∪ X5 , X1 ∪ X2 ∪ X3 ∪ X4 ∪ X5 ?
12. Eight job applicants are to be interviewed by eight members of a hiring
committee. Each will be interviewed twice. To avoid bias, each candi-
date is assigned their first interviewer at random; the second interviewer
is also chosen at random, but no candidate is to get the same interviewer
twice.
(i) How many different ways are there to schedule the first round of
interviews?
(ii) How many different ways are there to schedule the whole process?
Problems
|A ∪ C| = |A| + |B ∩ C| + |B ∩ C| − |A ∩ B ∩ C| − |A ∩ B ∩ C|.
recall that this subscripting technique is how we proved Theorem 2.3, the Bi-
nomial Theorem.) In the same way, some numbers of combinatorial interest
(such as a sequence of integers) have properties that become clear or easier
to prove when they are used as coefficients of a polynomial or an infinite se-
ries. These considerations motivate us to define the P generating function of a
sequence a0 , a1 , . . . to be the formal power series i≥0 ai xi .
The expression formal power seriesindexformal power series is understood
to mean that we do not evaluate the power series at any point, or concern
ourselves with the question of convergence necessarily. Indeed, some uses of
generating functions do not require infinite series at all; in this case we shall
assume that an = 0 for all n greater than some specific integer N .
Example 6.1: Suppose we wish to buy a dozen donuts from a shop with
varieties v1 , v2 , v3 , and v4 . We want between three and five donuts of variety
v1 (because the shop has only 5 available, and at least three people will want
one); similarly, we require 1 ≤ |v2 | ≤ 10, 4 ≤ |v3 | ≤ 6, and 0 ≤ |v4 | ≤ 7.
103
104 Introduction to Combinatorics
product
(x3 + x4 + x5 ) × (x + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 ) ×
(x4 + x5 + x6 ) × (1 + x + x2 + x3 + x4 + x5 + x6 + x7 ) (6.1)
and ask where terms involving x12 originate. If we multiply out the given
polynomials and do not collect like powers of x, a given term of x12 might
come from the x4 in the first factor, the x2 in the second factor, the x6 in
the third, and the 1 in the final factor. This would correspond to a dozen
donuts consisting of 4 of type v1 , 2 of type v2 , 6 of type v3 , and none of type
v4 . Similarly, any other way of making up a dozen donuts satisfying the given
constraints must correspond to exactly one term x12 of the product. Thus we
see that in general the coefficient of xn in the product above determines the
number of ways of making up a box of n donuts satisfying the constraints.
The product is
Now, multiplying out the product (6.1) above may seem only slightly easier
than enumerating possible solutions by hand; but there are reasons why the
product might be preferable. For instance, we might be faced with the same
problem for 18 donuts, or 10. The polynomial will give us the answers for
those problems with no additional work. The relative prevalence of computer
algebra systems, from Mathematica and Maple on down to some sophisticated
pocket calculators, means that multiplication need no longer be terribly time-
consuming. And finally, algebraic identities can in some cases reduce the effort
of calculating the product.
Example 6.2: Assume that we again want a dozen donuts from the same
shop, but now the shop has an unlimited supply (i.e., at least 12) of each
variety; the lower bound constraints still apply.
Rather than limiting each factor to x12 , we allow each factor to represent
an infinite series. We have
and since each factor is a geometric series we can use the familiar formula for
the sum of such a series to see that it is equivalent to the expression
x8 1
= x8
(1 − x)4 1 − 4x + 6x2 − 4x3 + x4 .
Generating Functions and Recurrence Relations 105
Now, polynomial long division (done with the coefficients in increasing or-
der) will allow us to compute a Maclaurin polynomial, and the coefficient of
x12 will be the solution to our problem. We get
x8 +4 x9 +10 x10 +20 x11 +35 x12 +56 x13 +84 x14 +120 x15+165 x16 +220 x17 +. . .
These figures conform well to our intuition that the numbers should be larger,
as there are fewer constraints (so there are more ways to make up a box of
donuts).
Just as we can calculate the values for the donut problem above, we can
use infinite series in a formal way to describe any infinite sequence of integers.
Consider the most basic example of this sort, the sequence
P∞ αn = 1. As we saw
in Example 5.2, it will be useful to recall fα (x) = i=1 1xi = x/(1 − x). In
calculus, we were concerned with the values of x for which the series converged;
in combinatorics, we ignore the question.
Another sequence of combinatorial import has a generating function P∞ that
may be simply computed. Suppose βn = n, n ≥ 0. Then fβ (x) = 1 ai xi =
x/(1 − x)2 . This formula is easily derived by differentiating the ordinary in-
finite geometric series, and multiplying by x. Note that since a0 = 0 we
begin the summation at i = 1; if we begin at i = 0, we get the same series.
Differentiating
P∞ 2 iagain, with another multiplication by x, gives us another for-
3
mula: 1 i x = x(1 + x)/(1 − x) . With these formulas, we are able to
find the generating function for any integer sequence produced by a quadratic
polynomial.
Example 6.3: Find the generating function for an = n2 .
ai xi and multiply by x.
P
Proof. Differentiate both sides of fa (x) =
We used the next theorem as part of doing Example 5.3, so we ought to at
least state it.
x
so fa (x) = (1−3x)(1−2x) .
More generally, it is true that if an is any sequence defined as a linear com-
bination of nth powers, the generating function will be rational. Furthermore,
its denominator will have roots equal to the reciprocals of the bases of the
nth powers. In the last example we had a linear combination of 3n and 2n ,
and the denominator of the generating function has roots 1/3 and 1/2. We
will explore other properties of the denominator later.
Generating Functions and Recurrence Relations 107
3x A B
= + ⇒ A = 1, B = −1.
(1 − 2x)(1 + x) 1 − 2x 1 + x
1 1
This yields fa (x) = 1−2x − 1+x ; we can use the geometric series formula
1 P i i 1 P i i
here. We know 1−2x = i≥0 2 x and 1+x = i≥0 (−1) x , so fa (x) =
i i i i n n
P P
i≥0 (2 − (−1) )x = i≥0 ai x . It follows that an = 2 − (−1) .
We could compute this formula in another way. Suppose we were to as-
sume that the sequence an had a representation as a linear combination of
exponential functions. Then an = rn would give us, via the recurrence, an
equation rn+1 = rn + 2rn−1 . Dividing by rn−1 yields a quadratic equation,
r2 − r − 2 = 0. This is called the characteristic equation of the recurrence.
Finding the roots gives us r = 2 or r = −1, the bases of the exponential
functions. We are now able to surmise that an = c1 2n + c2 (−1)n . Using the
given values for a0 and a1 we are able to solve for c1 and c2 to get the same
formula as above.
That method works for distinct roots. If there are repeated roots, we must
work a little harder.
Example 6.6: Let us consider an+1 = 2an − an−1 , with a0 = 1, a1 = 2.
It is easy to find a closed expression for an using a guess and a proof by
induction, but we will try generating functions. As with our first example, we
multiply by xn+1 and sum over n to arrive at:
Partial fractions will not assist us in this case. Instead, we turn for inspiration
to an earlier example, the sequence βn , which had as its generating function
fβ (x) = x(x − 1)−2 . We write this sequence as βn = (n + 0)(1)n and ask
whether a formula of the type an = (c1 n + c2 )1n will work. A little work
reveals an = n + 1.
Example 6.7: Solve the recurrence an+1 = 4an − 4an−1 , where a0 = −2,
a1 = 2.
The characteristic equation is x2 − 4x + 4 = 0, so the solution is an =
(c1 n + c2 )2n for some c1 and c2 . Using the given values of a0 and a1 we get
−2 = c2 and 2 = 2c1 + 2c2 . Solving for c1 gives an = (3n − 2)2n .
As a concrete example, we introduce the reader to a sequence of numbers
involved with a problem that is over 800 years old, about rabbits.
The Fibonacci numbers f1 , f2 , f3 , . . . are defined as follows. f1 = f2 = 1,
and if n is any integer greater than 2, fn = fn−1 +fn−2 . This famous sequence
is the solution to a problem posed by Leonardo of Pisa, or Leonardo Fibonacci
(Fibonacci means son of Bonacci) in 1202:
Careful use of the formula for f (x) will help us to represent this equation
in more understandable
P∞ terms. So, using Theorem 6.2, the first term in the
equation is i=2 fi+1 xi+1 = (f (x) − f1 x − f2 x2 ). We substitute similarly for
the other two terms to get
f (x) − f1 x − f2 x2 = xf (x) − f1 x2 + x2 f (x)
which we may solve for f (x), to get
x = f (x)(1 − x − x2 ) or f (x) = x/(1 − x − x2 )
We may confirm that polynomial long division, as in the earlier example,
produces the Fibonacci numbers (see Problem 6.4). But there is a more
useful and fascinating consequence of our calculation of f (x). Recall that for
the earlier case of the sequence an = 3n − 2n in Example 6.4, the generating
function was also a rational function, and that the bases of the exponents were
reciprocals of the roots of the denominator. Alternatively, as in Example 6.5,
we may use partial fractions or the characteristic equation.
First, we assume that the Fibonacci numbers may be represented by an
expression of the form fn = rn , r ≥ 1. Then the recurrence gives us rn+1 =
rn + rn−1 , and dividing by rn−1 gives us 2
√ a quadratic r − r −√ 1 with two real
roots, traditionally denoted φ1 = (1 + 5)/2 and φ2 = (1 − 5)/2. To find
fn we simply assume fn = c1 φn1 + c2 φn2 and use the initial values to solve for
c1 and c2 .
√ √ √ √
1+ 5 1− 5 6+2 5 6−2 5
f 1 = 1 = c1 + c2 , f 2 = 1 = c1 + c2
2 2 4 4
√ √
This gives us c1 = 1/ 5 and c2 = −1/ 5. This formula for the Fibonacci
numbers is sometimes called Binet’s formula, although Binet was not its first
discoverer. Different starting values yield a different sequence, but it is not
hard to see that the values f1 = 0, f2 = 1 will give the same numbers with
different subscripts, and likewise f1 = 1, f2 = 2. So, the “first” (in some sense)
set of initial values that gives us a different sequence is f1 = 1, f2 = 3. This
sequence has also been studied extensively; it is more commonly called the
sequence of Lucas numbers, after the mathematician Edouard Lucas. There
is a formula for the nth Lucas number Ln similar to the Binet formula for
Fibonacci numbers; see Problem 6.5.
The Fibonacci numbers represent the number of ways of writing an integer
as an ordered sum of 1s and 2s. More precisely, fn is the number of ways of
writing n − 1 as such a sum, for n ≥ 2. The proof of this statement comes
from asking how the sum begins. There are fn ways to write n − 1, and we
place a 1 at the beginning of such sequences to create some of the ways of
Generating Functions and Recurrence Relations 111
writing n as such a sum. Then there are fn−1 ways to write n − 2; we may
place a 2 at the beginning of any of these sequences to obtain ways of writing
n. It follows that fn+1 = fn + fn−1 . Now, f1 = 1 (which counts the empty
sum only) and f2 = 1 since we can only write 1 as a sum of a single 1 and no
2s. Thus we have the same recurrence and initial conditions as the Fibonacci
sequence; it follows by mathematical induction that the sequences are the
same. The Fibonacci numbers arise in other contexts as well; see Problem 6.7
for an example.
Our next example will concern a construction by the Greek mathemati-
cian Theon of Smyrna. At the time when Theon lived, through the early
second century AD, it was already known that the square root of two was
not rational. However, there was work done on finding a rational sequence
of approximations to the value, and it was Theon who found (see [44]) the
process that has become known as Theon’s ladder. We begin with the first
“rung” of the ladder by setting a0 = b0 = 1. Each successive rung is created
by setting an = an−1 + 2bn−1 and bn = an−1 + bn−1 . Then the rational num-
ber rn = an /bn is our nth approximation.
√ This gives us a1 = 3 and b1 = 2,
so that our second approximation to 2 is r1 = 1.5. Continuing, we will find
a2 = 7, b2 = 5, and r2 = 7/5 = 1.4.
Example 6.9: Find a closed form for the quantities an and√ bn and use
this closed form to show that the ratio rn indeed approaches 2.
We clearly cannot deal with these two intertwined recurrences as they stand,
so we must try to eliminate one of the sequences. We observe that the second
recurrence may be rewritten as an−1 = bn −bn−1 and therefore an = bn+1 −bn .
We substitute these values into the first recurrence to get
bn+1 − bn = bn − bn−1 + 2bn−1 or bn+1 = 2bn + bn−1.
Similar calculations will give us an+1 = 2an + an−1 , the same recurrence.
Using the characteristic equation and the values of a1 , a2 , b1 , and b2 as given
above, we arrive at the formulas for an and bn .
√ √ √ √
(1 + 2)n+1 + (1 − 2)n+1 (1 + 2)n+1 − (1 − 2)n+1
an = bn = √
2 2 2
Now we look at√the ratio rn = an /bn and take the limit as n goes to ∞.
We note that (1 − 2)n+1 is less than 1 in absolute value and goes rapidly to
0 as n increases.
√ √
√ (1 + 2)n+1 + (1 − 2)n+1
rn = 2 √ √
(1 + 2)n+1 − (1 − 2)n+1
√
When we replace the (1 − 2)n+1 with 0, we get the result.
112 Introduction to Combinatorics
This says that our recurrence is an = an−1 + an−2 − an−3 . We can compute
the value of an for small n; doing so for several values of n will give us initial
Generating Functions and Recurrence Relations 113
4x3 /3 + 2x2 + 2x + 1). Expanding the first factor out in series as far as x6 ,
we get
series((exp(x)-1)^2*(1+x+(1/2)*x^2+(1/6)*x^3)^2, x = 0, 10);
Exercises 6A
1. Find the generating function for the sequences:
(i) an = n3 .
(ii) bn = 3n2 − 2n − 1.
(iii) cn = n3 .
(iv) dn = 3n − 23 2n .
2. A bakery sells plain, chocolate chip, and banana-walnut muffins; on a
particular day, the bakery has three of each kind.
(i) How many ways are there to purchase a selection of n muffins?
(ii) How many ways are there if we wish at least one of each kind?
(iii) How many ways are there if we wish at least two banana-walnut
muffins, but have no restrictions on the numbers of the other kinds
of muffins?
(iv) How many ways are there to purchase n muffins if the bakery has
an unlimited supply of each kind? Find a recurrence relation for
this sequence.
116 Introduction to Combinatorics
3. Find the solution for the recurrence with given initial values:
(i) an+1 = an + 12an−1 , a0 = 1, a1 = 4.
(ii) an+1 = 4an − 4an−1 , a0 = −2, a1 = −2.
(iii) an+1 = an + 12an−1 , a0 = 1, a1 = 3.
(iv) an+1 = 4an − 4an−1 , a0 = 1, a1 = 2.
(v) an+1 = an + 12an−1 , a0 = 0, a1 = 1.
(vi) an+1 = 4an − 4an−1 , a0 = 0, a1 = 1.
4. Compute the first 12 Fibonacci numbers.
5. Find a generating function for an , the number of ways to represent the
integer n as an unordered sum of 1s and 3s. Use this generating function
to find a recurrence relation satisfied by an . Can you find a closed form
for this quantity?
6. Find the generating function for an = 2n − n; use this function to find
a recurrence that an satisfies.
7. Find exponential generating functions for the following sequences:
(i) an = n2 .
(ii) bn = 3n − 2n−1 .
(iii) cn = 2.
(iv) dn = 2n + 2.
Exercises 6B
1. Find the generating function for the sequences:
(i) an = n4 .
(ii) bn = 6n4 − 4n2 .
(iii) cn = n4 .
(iv) dn = 2n + 2(−1)n .
2. A supply cabinet contains four red pens, three blue pens, and three
black pens.
(i) How many ways are there for a staff member to take n pens?
(ii) How many ways if we wish one of each color?
(iii) How many ways are there if we want at least two red pens but have
no other restrictions?
(iv) How many ways are there to take n pens if the supply cabinet has
an unlimited quantity of each color? Find a recurrence relation for
this sequence.
3. Find the solution for the recurrence with given initial values:
(i) an+1 = an + 2an−1 , a0 = 1, a1 = 2.
(ii) an+1 = 2an − an−1 , a0 = 0, a1 = 1.
(iii) an+1 = an + 2an−1 , a0 = 1, a1 = −1.
(iv) an+1 = 2an − an−1 , a0 = 2, a1 = 1.
(v) an+1 = an + 2an−1 , a0 = 5, a1 = 4.
(vi) an+1 = 2an − an−1 , a0 = 1, a1 = 1.
4. Prove the given result about the Fibonacci numbers, for all positive
integers n.
(i) fn is divisible by 3 if and only if n is divisible by 4.
(ii) fn is divisible by 4 if and only if n is divisible by 6.
(iii) fn is divisible by 5 if and only if n is divisible by 5.
(iv) f1 + f2 + · · · + fn = fn+2 − 1.
(v) f1 + f3 + · · · + f2n−1 = f2n .
(vi) fn2 + fn+1
2
= f2n+1 .
5. Find the generating function for an , the number of ways to represent
the integer n as an unordered sum of 1s and 4s. Use this generating
function to find a recurrence relation satisfied by an . Can you find a
closed form for this quantity?
6. Find the generating function for the sequence an = 3n − 2n; use this
function to find a recurrence relation that an satisfies.
118 Introduction to Combinatorics
Problems
n
P
Problem P 7: Prove the convolution identity: if fa (x) = n≥0 an x and
n
fb (x) = n≥0 bn x , then fa (x)fb (x) is the ordinary generating function for
the sequence cn = a0 bn + a1 bn−1 + · · · + ai bn−i + · · · + an b0 .
2
Problem 8: Suppose that P∞h(n) = an + bn + c for some real numbers a, b, c;
the generating function n=0 h(n)x is a rational function p(x)/(1 − x)3 for
n
7.1 Introduction
One of the basic purposes of combinatorics is enumeration, and we have seen
many ways to enumerate arrangements of objects. The binomial coefficients
enumerate ways of choosing a subset of distinct objects from a set; factorials
and permutation numbers enumerate ways of choosing an ordered subset; and
so on. In general, we distinguish several classes of problems involving enumer-
ation of arrangements of objects. The objects may be distinct or identical;
the arrangements may be considered distinct when order is changed (order
important ) or not (order unimportant ); and we may distinguish among the
classes in which they are arranged, or not. Also, we may ask whether repeti-
tion is allowed, or not (and if so, whether the repetition may be unlimited);
whether all objects must be arranged; and whether all the classes into which
they are to be arranged must receive at least one object.
For example, consider the number of ways of putting Halloween candies
into two bags. If the candies are all identical, there are clearly fewer ways
of arranging them than if all the candies are distinct. Again, if the bags are
considered identical, there are fewer ways than if we have already assigned
one bag to a particular child. Of course, if the candies are distinct it is not
likely that the child will be terribly concerned about whether the chocolate
bar went into the bag before or after the lollipop; if this makes a difference,
then clearly there are more ways to arrange the candies. If we decide that
repetition is allowed, then placing the chocolate bar into one bag does not
mean that the other bag cannot also get a chocolate bar; we might have
a limited number of chocolate bars available, or not. Are we allowed not
to distribute (say) the lemon drop, or must we use all the available candy?
Is it fair to leave one of the bags empty? These questions also affect the
number of ways in which the distribution might be done. We have already
seen ways to enumerate arrangements for some of these cases; the purpose
of this chapter is to discuss enumeration in some cases that we have not
before. This discussion will include quantities for which (unlike the binomial
coefficients, for instance) no easy formula exists. These quantities are given
the names of the mathematicians with whom they are chiefly associated.
121
122 Introduction to Combinatorics
n 0 1 2 3 4 5 6 7
Cn 1 1 2 5 14 42 132 429
It was not until the 1830s that Catalan investigated the question of how
many ways one can correctly arrange n pairs of parentheses. Here “cor-
rectly” means that the expression makes sense, i.e., that each right paren-
thesis is matched by a preceding unique corresponding left parenthesis and
vice versa. Thus, for n = 0 and n = 1 we get 1; for n = 2 we get 2,
enumerating the set {(()), ()()}; and for n = 3 we find five ways, namely
{((())), (())(), ()(()), (()()), ()()()}. Because the sequence begins 1, 1, 2, 5, . . .
we naturally wonder whether it is the same sequence as Euler’s.
If we let Cn denote the number of ways to correctly arrange n pairs of
parentheses, we can find a recurrence that relates each value to the preceding
values. Take any correct arrangement of n pairs of parentheses, n ≥ 1, and
look at the leftmost parenthesis. It is matched by a right parenthesis elsewhere
in the expression, either immediately following or at the end or somewhere in
the middle of the expression. Because the expression is a correct arrangement,
there must be a correct arrangement of 0 or more pairs of parentheses between
this first parenthesis and the corresponding right parenthesis, and a correct
arrangement of 0 or more pairs following the corresponding right parenthesis.
Suppose there are k pairs of parentheses between it and its “mate.” Then
there are n − k − 1 pairs of parentheses following the mate. How many ways
can this be accomplished for a given value ofP k? Clearly, there are Ck ×Cn−k−1
ways. Summing over k, we see that Cn = 0≤k≤n−1 Ck × Cn−k−1 . Because
this sequence has the same initial values and satisfies the same recurrence as
the sequence of polygon triangulations, they are identical.
is an internal point of the original rooted binary tree, the two trees we get
after removing it have k and n − k − 1 internal points, for some value k with
0 ≤ k ≤ n − 1. Now,
Pn−1as with the problem of triangulations of the polygon, we
may write an = k=0 ak an−k−1 . The sequence an has the same initial terms
and satisfies the same recurrence as the Catalan numbers so it is the same
sequence.
We spent all of Chapter 6 discussing generating functions. The Catalan
numbers will provide us with a challenge.
Proof. We will use the convolution identity from Problem 6.8. Let C(x) =
xn = 1 + x + 2x2 + 5x3 + . . . . This identity gives us:
P
i≥0 Cn
X
C 2 (x) = (C0 Ci + C1 Ci−1 + · · · + Ci C0 ) xi .
i≥0
The Catalan recurrence with which we began this section tells us that the
parenthesized
P expression on the right side of this equation is just Ci+1 , so
C 2 (x) = i≥0 Ci+1 xi or C 2 (x) = 1 + 2x + 5x2 + 14x3 + . . . . (The reader
should confirm this by squaring the polynomial 1 + x + 2x2 + 5x3 + 14x4 ,
neglecting terms past x4 .) Now we multiply both sides by x and add 1:
xC 2 (x) + 1 = 1 + x + 2x2 + 5x3 + 14x4 + · · · = C(x). Now what are we to make
of the equation xC 2 (x) − C(x) + 1 = 0? This is just a quadratic equation in
C, for any particular value of x. We may apply the quadratic formula with
a = x, b = −1, and c = 1. We arrive at two possibilities:
√
1 ± 1 − 4x
C(x) = .
2x
To determine whether to use the plus or the minus, look at C(0); we get
C(0) = 1 + 1 · 0 + 2 · 02 + · · · = 1. Now, setting x = 0 in the formula above
126 Introduction to Combinatorics
a problem, you merely invent a symbol, define the symbol to be the solution
to the problem, and then announce that you’ve solved the problem, giving the
symbol as the solution. In this tradition, we define the Stirling number of the
second kind, nk , to be the number of ways to divide n distinct objects into k
now solved the problem; ifwe are given nine candies and six children, we may
distribute the candies in 6! 96 ways. Other notations for the Stirling numbers
(k)
of the second kind include Sn and S(n, k); our notation was popularized by
Knuth ([48], [64]),who attributes it to Karamata ([55]). Knuth also suggests
that the notation nk be read as “n subset k.”
The irritated demands of those unmoved by the tradition discussed in the
previous paragraph suggest we look more deeply into the properties of the
numbers nk in order to produce numerical values. To this end, we establish
a few conventions. For instance, we will define 00 = 1 for much the same
4 3 3 2 2 2 2
= +2 = +1 +2 +2
2 1 2 0 1 1 2
128 Introduction to Combinatorics
Example 7.4: How many ways are there to factor the number 2 · 3 · 5 · 11 ·
23 = 7590 into a product of two factors each greater than 1? How many for
three such factors?
It is clear that each of these factors needs to use some of the distinct primes
in the unique factorization of 7590. Accordingly, we take two boxes and put
prime factors into them. As there are five prime factors and two boxes, we
find 52 = 15. Note that we count the factorization 2 × 3795 the same as
5 × 2, for instance, because the boxes are identical. In the same way,
3795
3 = 25, so we have 25 ways of writing 7590 as a product of three factors,
each bigger than 1.
Example 7.5: Angered by all the candies being given to children at the
beginning of this section, a group of indignant parents take five distinct pam-
phlets on the dangers of childhood obesity to give to two textbook authors. In
how many ways may this be done if the two authors are considered distinct?
In how many ways if the authors are considered identical? In either case, no
author escapes being given at least one pamphlet, and there is only one copy
of each of the five pamphlets.
Here n = 5 refers to the pamphlets, and k = 2 refers to the authors. From
the table, 52 = 15, so if the authors are distinct the answer is 2! × 15 or 30,
and if the authors are identical we get 15.
.
Example 7.6: Properly chastened, the authors meet with three indignant
parents and offer them a collection of six distinct healthful snacks. (The
authors never offer healthy snacks, as by definition healthy implies that the
Catalan, Bell, and Stirling Numbers 129
snacks are still alive and potentially able to fight back. Ethical, dietary, and
legal considerations forbid.) Assuming the three parents are distinct, in how
many ways can this be done if each parent is to receive at least one snack? In
how many ways if a parent may refuse a snack (all snacks are distributed)? In
how many ways if we do not require that all snacks be distributed, and any
parent may refuse a snack?
The second problem must be done in pieces. If all three parents accept a
snack, 540 is still the answer; if one parent refuses, there are three ways to
choose a parent to refuse and 2! × 62 = 62 ways to distribute the snacks to
the other two parents, so we get another 186 possibilities. Then if two parents
refuse, we get another three possibilities
(three choices of the parent to accept
all six snacks, or if you like 31 × 61 = 3). Adding these, we find a total of
729 possible distributions of snacks.
The third problem is the easiest or most difficult, and may be solved by
considering the trash can as a fourth potential snack recipient. If all four
possible recipients get a snack, we have 4! × 64 = 1560. If one recipient
one recipient, there are four possibilities. Adding these numbers yields 4096
ways. Realizing that this answer is just 46 , we see that we could have saved
ourselves much trouble by saying: Associate with each snack a number from
{0, 1, 2, 3} according to which recipient receives it. Placing these numbers in
order gives us a six-digit base-4 number, of which there are 46 .
the formula. Forn the ocase in which one recipient gets no object, we count
r n
1 × (r − 1)! × r−1 , which is equivalent to the k = r − 1 summand. In
n o n o
general, if i recipients get no objects, we have ri ×(r−i)!× r−i
n
= r! n
i! r−i
130 Introduction to Combinatorics
which is the r − ith summand. On the other hand, the quantity we are count-
ing is the number of n-digit base-r integers, of which there are rn .
This formula is one of a number of identities for nk for specific k; see the
problems for more examples. Each may be proved by induction or combina-
torial techniques. There is another recurrence relation for nk that may be
useful in computing the entries in a table such as the one given above.
Pn−1
Substituting 2 for k, we get n2 = i=0 n−1
i i
n Pn−1 n−1 i 1 ; since 1 = 1 for
n−1
i > 0, we have 2 = i=1 i = 2 − 1 by the binomial theorem.
The proof is left to the reader (see Problem 6.7). Note that B0 is 1.
Example 7.11: Find B6 .
The recurrence gives B6 = B0 + 5B1 + 10B2 + 10B3 + 5B4 + B5 . We may
compute these by summing rows in the triangle, or by recursively applying
Theorem 7.6 to get B1 = 1, B2 = 2, B3 = 5, B4 = 15, and B5 = 52. This
gives us B6 = 1 + 5 + 20 + 50 + 75 + 52 = 203. This corresponds to the sum
of the sixth row of the triangle in Section 7.3.
Another approach is called the Bell triangle. Just as binomial coefficients
may be computed easily by means of Pascal’s triangle, the Bell numbers may
be computed by a triangular array. We create the array by means of the
following rules:
1. The first row consists of the number 1 by itself.
2. Each row is one entry longer than the row before it.
3. The first item in each row is equal to the last item in the preceding row.
4. Each entry after the first is the sum of the entry to its left and the entry
directly above that entry.
Applying these rules, we get the following table.
1
1 2
2 3 5
5 7 10 15
15 20 27 37 52
52 67 87 114 151 203
The rightmost entries give us a list of Bell numbers; B0 = 1, B1 = 1,
B2 = 2, B3 = 5, B4 = 15, B5 = 52, and B6 = 203. This is only a small
selection of the properties of the Bell numbers; we refer the interested reader
to ([42]), also found in the CD-ROM collection ([43]) for a very readable
discussion. More technical details and identities may be found in [48], [63],
and [139].
The unsigned Stirling numbers of the first kind may also be viewed as the
coefficients of the polynomial [x]k = x(x + 1) . . . (x + k − 1) (the “rising
factorial”). For example, where [x]3 = x(x − 1)(x − 2) = x3 − 3x2 + 2x,
we have [x]3 = x(x + 1)(x + 2) = x3 + 3x2 + 2x.
These numbers are more easily calculated than Stirling numbers of the
second kind; we simply multiply out the polynomial [x]k = x(x − 2) . . . (x −
k + 1). It is also easy to find a recurrence for signed or unsigned Stirling
numbers of the first kind.
Replacing the falling factorial on the right with the equivalent sum gives us:
m m−1
X m − 1
X m j
x = (x − m + 1) xj
j=0
j j=0
j
The next result requires a definition from the theory of permutation groups.
A permutation of a set of n elements is a bijection from that set to itself. A
cycle of a permutation is a subset of the elements with the property that
each member of the subset is mapped to any other member of the subset by
repeated applications of the permutation. For example, consider the permu-
tation σ on the set {1, 2, 3, 4, 5, 6} given by the table below.
Catalan, Bell, and Stirling Numbers 135
n 1 2 3 4 5 6
σ(n) 3 4 5 2 3 6
By applying σ repeatedly to the element 1, we see that σ(1) = 3, σ 2 (1) =
σ(3) = 5, and σ 3 (1) = σ(5) = 1; so the set {1, 3, 5} is a cycle. The other
cycles are {2, 4} and {6}. Groups of permutations are discussed in Chapter 8.
COROLLARY n 7.9.1
There are m permutations on n letters with m cycles.
Proof. We establish a one-to-one correspondence between ways to seat n
people at m tables and the specified permutations. Given a seating, let σ be
the permutation that maps i to j if and only if person i is sitting immediately
to the left of person j. Conversely, given a permutation with m cycles, take
the people whose labels correspond to the elements of a cycle, and seat them
at a table in the order they appear in the cycle; repeat this procedure until
all m cycles have been turned into seats at all m tables. This process gives
us a bijection, so the two sets have the same number of elements.
As with Stirling numbers of the second kind, we may present them in the
form of a table and refer to it, shown below. To extend the table or verify
any entry in it, choose an element. Multiply that element by the number n
at the left of its row, and subtract it from the element on its left (or 0 if there
is no element to the left). The result should be the number below the chosen
element.
n\k 0 1 2 3 4 5 6
0 1 0 0 0 0 0 0
1 0 1 0 0 0 0 0
2 0 −1 1 0 0 0 0
3 0 2 −3 1 0 0 0
4 0 −6 11 −6 1 0 0
5 0 24 −50 35 −10 1 0
6 0 −120 274 −225 85 −15 1
Exercises 7A
1. A ticket-taker sells tickets to a tacky tatting show. Each tatting ticket
is ten dollars. If there are 2n customers lined up to take tickets to the
tatting show, and n of them have $20 bills and the other half have $10
bills, in how many ways can they line up so that the ticket-taker will
always have correct change (she begins with no change)? It may help
to represent the line as “(” for a customer with a $20 bill and “)” for a
customer with a $10 bill.
3. Place 2n dots in a row along the x-axis, and imagine that we connect
pairs of dots with arcs that curve up into the first quadrant. We are to
138 Introduction to Combinatorics
do this so that each dot is connected with exactly one other dot, and
with no arcs crossing one another; show that Cn is the number of ways
this can be done.
9. How many ways are there to distribute six distinct chocolate rabbits
into three identical Easter baskets, where each basket is to receive at
least one chocolate rabbit? In how many ways can this be done if the
baskets are distinct?
10. Repeat the previous exercise if we do not have to distribute all six rab-
bits.
11. Five dishonest lobbyists set out to bribe three corrupt politicians. If each
politician receives at least one bribe, and each lobbyist offers a bribe to
exactly one politician, in how many ways can we assign lobbyists to
politicians, assuming the politicians are distinct?
12. Five dishonest lobbyists are caught engaging in bribery by federal au-
thorities, and thrown into two jail cells. If each jail cell is to hold at
least one lobbyist, in how many ways can we arrange them? Assume
the cells are identical.
13. Six investors wish to invest their savings into four mutual funds; they
have eight funds from which to choose, and each investor will put his
or her savings into just one fund. In how many ways can four funds
be chosen and the money invested? Assume the funds are distinct and
each of the four chosen funds receives some money.
17. We have six people who will be seated at two circular tables. How many
ways can we do this if the tables are identical? How many ways if one
table is distinguished?
Exercises 7B
1. An election takes place in which each of two candidates A and B will
receive n votes; there are 2n voters. In how many ways can the voters
line up so that candidate B will never be in the lead? It may help to
represent the line with a “)” for a voter for B and “(” for a voter for A.
2. Show each of the distinct ways of properly pairing up four pairs of
parentheses.
3. Use the Catalan recurrence to verify the table value of C6 .
4. Use Theorem 7.1 to calculate C8 .
n o
i
5. Make a 5 × 5 matrix whose (i, j)-entry is j . Calculate the inverse
of this matrix (by hand, with a calculator, or using a computer algebra
system such as Mathematica or Maple). Compare the entries in this
inverse with the Stirling numbers of the first kind.
6. Use the recurrence to calculate k7 for k = 5, 6, 7.
7. How many ways are there to factor the number 2×3×5×11×23 = 7, 590
into a product of two factors each greater than 1?
8. In how many ways can we distribute our last seven (distinct) candy
bars on Halloween night to two identical trick-or-treaters if we ensure
each child gets at least one candy bar? How many ways are there if the
trick-or-treaters are distinct (different costumes)?
9. Repeat the previous exercise in the case where we do not need to dis-
tribute all the candy bars.
10. Seven federal agents set out to investigate three politicians suspected of
being corrupt. In how many ways can this be done, assuming that each
politician is investigated by at least one agent, and the politicians are
considered distinct?
11. Three corrupt politicians are sent to two luxurious minimum-security
penal institutions. If each institution receives at least one politician,
and the institutions are identical, in how many ways can we do this?
140 Introduction to Combinatorics
12. Seven investors wish to invest their savings into four mutual funds; they
have six funds from which to choose, and each investor will put his or her
savings into just one fund. In how many ways can four funds be chosen
and the money invested? Assume the funds are distinct and each of the
four chosen funds receives some money.
13. How many ways are there to write 385 = 5 × 7 × 11 as a product of
distinct integers? Write out each product.
14. How many partitions of a set of seven elements are there?
15. Use the recurrence of Theorem 7.7 to find 71 , 72 , and 73 .
16. We have six people who will be seated at four circular tables. In how
many ways can we do this if the tables are identical? In how many ways
if one table is distinct from the other two?
Problems
√
1− 1−4(x)
Problem 3: Find the reciprocal of the generating function C(x) = 2x
and rationalize the denominator. Now use Newton’s binomial theorem, an in-
finite series from calculus, or a computer algebra system such as Mathematica
or Maple to expand 1/C(x) in an infinite series. What sequence does this
reciprocal function generate?
Problem 4:
2(2n + 1)
(i) Use the formula of Theorem 7.1 to show Cn+1 = Cn .
n+2
n
Y 2(2i + 1)
(ii) Show Cn+1 = .
i=0
i+2
Cn+1
(iii) Find lim .
n→∞ Cn
n o
p
Problem 5: Show that if p is an odd prime, then p−1 is a multiple of p.
n
Problem 6: Show that if n is odd then 2 is divisible by 3.
Catalan, Bell, and Stirling Numbers 141
8.1 Introduction
In this chapter we discuss how to find the number of ways of coloring
objects (such as seats at a circular table, or charms on a charm bracelet) that
are distinct with respect to certain operations. Thus, we say two colorings
of seats at a circular table are the same (or equivalent, in the sense of an
equivalence relation) if one coloring may be transformed into another by a
rotation. In the same way, colorings of beads on a necklace or charm bracelet
may be considered equivalent under a rotation, or when the necklace is flipped
over.
Suppose we wish to color each corner of a square one of two colors. In how
many ways can this be accomplished? We can start off by naı̈vely dividing
the question into cases. There are two ways (one for each color) if we are to
use exactly one of the colors, so that the square is all one color. If we are to
use both colors, there are more possibilities. So we might do three corners
in color c1 , and the other in color c2 ; or we might do two corners in color
143
144 Introduction to Combinatorics
c1 and the other two in color c2 . In the second case, we realize that there
is a difference if adjacent corners are to get the same color, or not. At this
point, the problem appears to be tedious and simply a matter of eliminating
possibilities by hand. For a large problem (as, say, a dozen seats and four
colors), this approach is wholly inadequate. A more effective approach uses
some basic facts of symmetry groups; we begin by discussing groups.
The reader should be familiar with the set of integers modulo n, denoted Zn ,
under addition, which we saw in Chapter 4. For instance, Z4 = {[0], [1], [2],
[3]}; the group operation + behaves like ordinary addition for small numbers,
and gives us the remainder upon division by 4, so for example [3] + [2] = [1]
in the group. The group axioms are satisfied; the identity element is [0],
each element has an inverse (so [1]−1 = [3], for instance), and the operation
is clearly closed since the only remainders possible upon division by 4 are
0 through 3. We may think of these elements as being functions from the
set {0, 1, 2, 3} to itself as well. So we may consider [1] to be the function
f (n) = n + 1(mod 8); this means that [1] is the function that takes 1 to 2,
2 to 3, and 3 to 0. It is also common to represent these functions as acting
on the set {1, 2, 3, 4}, and we will use this convention when we are looking at
symmetries of objects.
For the most part, we will consider the elements of a group to be functions
acting on the set S = {1, 2, . . . n} but may also use, for example, a set of differ-
ent ways to color an object. More abstract definitions of the group include the
axiom that the operation ◦ is associative, meaning that τ ◦ (σ ◦ π) = (τ ◦ σ) ◦ π.
This clearly holds for composition of functions, and for addition modulo n.
The student should notice that our notation differs significantly from the no-
tation used in many abstract or modern algebra texts. In many texts, the
Symmetries and the Pólya–Redfield Method 145
1 2
4 3
FIGURE 8.1: Square with numbered corners.
This function ρ will rotate the circle one turn clockwise; in two-line form,
this is denoted
1 2 3 4
.
2 3 4 1
The same permutation, written in cycle notation, is (1234). In the two-line
notation, we evaluate ρ(1), for instance, by looking for the column in which
1 is in the top row; the second row entry in that column is ρ(1). In cycle
notation, we calculate ρ(1) by looking for the first number in the brackets
with 1 directly to the right of 1. To find ρ(4) using cycle notation, we see that
nothing is to the right of 4 within that set of brackets, so we return to the
first number, which is 1; thus ρ(4) = 1. The name is a reference to applying a
permutation σ to an element of the set S repeatedly; it causes that element to
“cycle” through the values in that cycle of the permutation. This permutation
is exactly equivalent to the element [1] of Z4 , as we saw above.
Example 8.1: Find the cycle notation for the permutation
1 2 3 4 5
.
3 5 1 2 4
back to 2. Thus the cycle notation is (13)(254). This permutation may also
be written (542)(31), for instance, so the cycle representation is not unique in
general.
Example 8.2: Find the two-line notation for the permutation whose cycle
form is (12)(3)(45). (It is more common to omit elements that are sent to
themselves, or fixed points, as they are called; so the permutation might be
written (12)(45).)
To find the two-line notation, we begin by listing the top line, so we get:
1 2 3 4 5
.
ee eρ ρe ρρ
ee ee eρ ρe ρρ
eρ eρ ee ρρ ρe
ρe ρe ρρ ee eρ
ρρ ρρ ρe eρ ee
The reader should check the multiplication in each case.
Symmetries and the Pólya–Redfield Method 147
We will employ both cycle notation and two-line notation to represent per-
mutations as we continue with our discussion of groups. In particular, the
lengths of cycles and the numbers and kinds of fixed points will be important.
Example 8.4: Find the group of permutations that describe the symme-
tries of the square shown in Figure 8.1.
We have already mentioned the rotation ρ that describes rotation by 90◦ ;
the rotation ρ2 that describes rotation by 180◦ , the rotation ρ3 (270◦ ) and e
are the remaining planar motions that take the square into itself. The other
motions are four reflections that take the square out of the plane. We may
reflect the square about the line passing through the points 1 and 3, or 2 and
4, or through the vertical line bisecting the square, or the horizontal line that
bisects the square.
◦ e ρ ρ2 ρ3 α β γ δ
e e ρ ρ2 ρ3 α β γ δ
ρ ρ ρ2 ρ3 e γ δ β α
ρ2 ρ2 ρ3 e ρ β α δ γ
ρ3 ρ3 e ρ ρ2 δ γ α β
α α δ β γ e ρ2 ρ3 ρ
β β γ α δ ρ2 e ρ ρ3
γ γ α δ β ρ ρ3 e ρ2
δ δ β γ α ρ3 ρ ρ2 e
Since we have found no new symmetries, we have a group (and in fact have
found all the symmetries of the square). The reader will notice that each row
and column contains the identity e as well as each other element of the group.
This group is variously called the dihedral group on four letters or the octic
group, and is denoted D4 .
A number of points should be made here. First of all, notice that ρ ◦ α = γ,
but α ◦ ρ = δ. Unlike many common binary operations, then, function com-
position is not commutative in general. Groups in which the binary operation
is commutative are called abelian. All the groups Zn are abelian, because ad-
dition (and addition modulo n) is commutative. Also, the Cartesian product
148 Introduction to Combinatorics
of two abelian groups is an abelian group; the proof of this assertion is left to
Problem 8.2.
Next, if we ignore the reflections α, β, γ, and δ, we get a set of elements
{e, ρ, ρ2 , ρ3 }. This set forms a group as well; it is closed under composition
and each element has its inverse (the inverse of ρ is ρ3 , and ρ2 is its own
inverse). This is the group of rotations, and is referred to as the cyclic group
on four letters, denoted C4 . In general, any regular n-sided polygon has a
group Dn of 2n symmetries that contains the n rotations of the group Cn and
n reflections about n axes of symmetry. For any n, Cn is abelian, but Dn is
not, for n ≥ 3. It is worth noticing that the group Zn is essentially the same
as the group Cn ; that is, if we take the element [1] of Zn and write it as ρ,
and write [2] and ρ2 , and so forth, we get the same multiplication table. If
we have two groups that, under a suitable renaming of the elements, have the
same multiplication table, we say the groups are isomorphic, and the function
that maps an element of one group to the corresponding element of the other
is called an isomorphism.
We define a subgroup of a group G to be a subset of G that forms a group;
that is, H is a subgroup of G if H ⊆ G, H includes the identity e, and H is
closed under the group operation and under inverse. Thus, we have seen that
Cn is a subgroup of Dn . When we define Sn to be the set of all permutations
of a set of n objects, we call Sn the (full) symmetric group on n letters, and Dn
is a subgroup of Sn . Another subgroup of D4 is {e, α, β, ρ2 }; we will denote
this group by K. Confirmation that this is a subgroup is left to Problem 8.3.
We observe that the function α of D4 sends 1 to 1, and 3 to 3; 1 and 3
are called fixed points of the permutation α. Clearly, every point is a fixed
point of the identity e; also, non-identity elements of Cn have no fixed points.
We will see that fixed points are a useful idea when we count distinct ways to
color an object. The notation F P (σ) will mean the set of fixed points of the
permutation σ, so that F P (α) = {1, 3}.
A group partitions the elements of the set S into orbits; the orbit of an
element of S is the set of all elements of S to which it may be sent by one
of the functions of the group. The group is said to be transitive on S if
there is only one orbit. Equivalently, G is transitive if and only if, given any
two elements a and b of S, there is an element σab with the property that
σab (a) = b. Other characterizations of transitivity exist; see Problems 8.4
and 8.7.
Example 8.5: Find the orbits of the group K.
We observe that β and ρ2 exchange 1 and 3; no element of K takes 1 to 2
or 4, so one orbit is the set {1, 3}. Now, α and ρ2 both take 2 to 4, but no
element of K takes either of 2 or 4 to either of 1 or 3. So there are two orbits
of K, and S = {1, 3} ∪ {2, 4}.
A symmetry of the square may be thought of as a permutation, not just of
the corners of the square, but of the sides of the square as well. For example,
Symmetries and the Pólya–Redfield Method 149
if we label the sides of the square shown in Figure 8.1 by the numbers of the
corners, we may look at ρ as the permutation that sends side 12 to side 23,
side 23 to side 34, and so on. We sometimes say that this permutation of the
sides is induced by ρ, and the group of permutations of the corners induces
a group of permutations of the sides. It is not hard to see that the group of
permutations of the corners is in fact isomorphic to the group of permutations
of the sides. We also say that the group acts on the sides.
It is worth noticing that the permutations of the sides induced by the
permutations of the corners will not have the same numbers of fixed points in
general as the permutations that induce them. For instance, α = (24) fixes
two corners, but the permutation of the sides induced by α exchanges side 12
with 14, and side 23 with 34. On the other hand, γ = (12)(34) does not fix
any corner, but the induced permutation fixes the sides 12 and 34.
1 a 2 1 a 2 1 a 2
f b f b f b
6 3 6 3 6 3
e c e c e c
5 d 4 5 d 4 5 d 4
on the two quadrilaterals. Both the elements e and α leave the quadrilaterals
unchanged, and δ and ρ3 exchange the two quadrilaterals.
result.) In general, all the corners that are in the same cycle as corner 1 must
get the same color as corner 1, and the same for each other corner.
Example 8.8: Find all colorings of the square with four colors that are
fixed by the permutation ρ.
Since ρ has only one cycle, all four corners must get the same color. Since
we have four colors to choose from, we have exactly four colorings; C1 , in
which all four corners get color c1 , C2 with all color c2 , C3 with all color c3 ,
and C4 with all color c4 .
Proof. We may choose one of k colors to use for each of the points in the
first cycle; then all the points of that cycle must receive the same color. We
choose one of the k colors independently for a point of the next cycle (if the
permutation has more than one cycle). When we perform this process for each
of the n cycles, the multiplication principle tells us that there are k n ways to
color the figure.
C1 and C2 are equivalent (so that there is some σ in G for which σ(C1 ) = C2 ).
Then for any τ in the stabilizer of C1 (so τ (C1 ) = C1 ), we have σ ◦ τ (C1 ) = C2 .
It follows that each equivalent coloring C2 of C1 is the image of C1 for exactly
|Stab(C1 )| permutations in G. That means there are |G| / |Stab(C1 )| such
equivalent colorings. Let |[C]| denote the number of colorings equivalent to
the coloring C (we use square brackets to denote an equivalence class). Then
Example 8.9: How many ways can we color a length of board with up
to three colors if we place one color at each end and one color in the middle?
Two colorings are equivalent if one may be obtained from the other by flipping
the board end-for-end (corresponding to the group C2 ).
We see that there are 27 ways to color the board in all (without considering
equivalence classes); there are three colors for the left end, three for the middle,
and three for the right end, giving 33 . Now, the temptation to simply divide
by two (since each coloring would appear to be equivalent to exactly one other,
obtained by rotating the board by 180◦ ) might be great, but it would lead us
to conclude that there are 27/2 or 13 21 colorings, surely an absurd result. We
will count the equivalence classes of colorings twice, once by combinatorial
reasoning and once using Theorem 8.2. First, consider that the only colorings
that are different but equivalent are the colorings that are not fixed by ρ,
Symmetries and the Pólya–Redfield Method 153
the permutation that exchanges the colors on the left and right ends of the
board. We see that ρ has just two orbits; one orbit consists of the left and
right ends of the board, and the other consists of the middle of the board.
By Theorem 8.1, ρ fixes 9 colorings, so there are 18 it does not fix. These
18 colorings give us nine equivalence classes. The nine colorings fixed by ρ
are equivalent only to themselves; each is its own equivalence class. Hence we
have 18 different equivalence classes (ways to color the board).
Now, using Theorem 8.2, we use |G| = 2, and |F P (e)| = 27 because every
possible coloring is fixed by the identity permutation. Since |F P (ρ)| = 9 by
the foregoing reasoning, N = (27 + 9) /2 = 18.
5
5
6 4
4 3
1 3
1 2
2
Example 8.11: In how many ways can we color the corners of the pentagon
on the left of Figure 8.3 with k colors if we assume colorings are equivalent
under reflection about the vertical axis? This reflection corresponds to the
permutation (12)(34); the figure’s symmetry group thus has two elements
(this permutation and the identity). Clearly, every coloring is fixed by the
identity permutation; to compute the number of colorings fixed by the other
permutation, we observe that corners 1 and 2 must receive the same color,
and corners 3 and 4 must receive the same color.
154 Introduction to Combinatorics
There are k 5 total ways to color the corners with k colors (multiplication
principle); all k 5 of them are fixed by the identity permutation. The other
permutation fixes only k 3 colorings, because we may choose any of k colors
for corner 1, any of k colors for corner 2, and any of k colors for corner 3; the
colors for the other corners are determined. The Cauchy–Frobenius–Burnside
theorem says that there are 21 (k 5 + k 3 ) non-equivalent colorings.
Example 8.13: How many ways are there to color the pentagon of Fig-
ure 8.3 with k colors?
Symmetries and the Pólya–Redfield Method 155
The permutations consist of the identity e and the reflection (12)(34). These
have cycle enumerators of z15 for e and z11 z22 for the reflection. Our cycle index
is thus C(z1 , z2 ) = 12 (z15 + z1 z22 ). Inserting k for each z, we get (k 5 + k 3 )/2,
just as with the example of the last section.
THEOREM 8.3
Given a figure with a symmetry group G having cycle index C(z1 , . . . zn ),
the number of colorings not equivalent under action of G using k colors is
C(k, . . . k).
The detailed proof is omitted. Roughly speaking, however, each cycle enu-
merator evaluated at k will give the number of k-colorings that are fixed
under the action of the corresponding permutation. Thus, the cycle index
is the right-hand-side of the equation of Theorem 8.2 when evaluated at k,
giving us the number of equivalence classes of colorings.
Example 8.14: Count the colorings of the hexagon of Figure 8.3.
For this hexagon, two colorings are equivalent under vertical reflection,
horizontal reflection, or rotation by 180◦ . The symmetry group here thus
(with the identity) has four elements; they are α = (13)(46), β = (16)(25)(34),
ρ = (14)(25)(36), and e. The cycle enumerators are z12 z22 for α, z23 for β and
ρ, and z16 for e. Thus, the total number of non-equivalent colorings with k
colors is C(k) = 14 (k 6 + k 4 + 2k 3 ).
a 2 b 4 c
1 3 5
d 7 e 6 f
It is important to make sure that the cycle index is appropriate to the ob-
jects being counted. Consider, for instance, the rectangle shown in Figure 8.4.
We will consider coloring the corners, which are labeled with letters a through
f , and the sides, labeled with the numbers 1 through 7. In each case, we con-
sider two colorings equivalent if one is moved into the other by reflection
across the horizontal axis, reflection across the vertical axis, or rotation by
180◦ . Notice that this is the group D2 (two rotations and two reflections, if we
count the identity as a 360◦ rotation), even though it is acting on six corners
and seven sides.
156 Introduction to Combinatorics
Example 8.15: How many non-equivalent ways can we color the corners
of Figure 8.4 with k colors?
The four permutations are: the identity, fixing each of the six corners;
the horizontal reflection, corresponding to the permutation (ad)(be)(cf ); the
vertical reflection, corresponding to (ac)(df ); and the rotation, (af )(be)(cd).
The cycle enumerators are, respectively, z16 , z23 , z12 z22 , and z23 . This gives
us a cycle index of 14 (z16 + 2z23 + z12 z22 ). This gives us a total of C(k) =
(k 6 + k 4 + 2k 3 )/4 ways to color the corners with k colors.
Example 8.16: How many non-equivalent ways can we color the sides
with k colors?
The same four symmetries now have different cycle enumerators. The hor-
izontal reflection is (27)(46); the vertical reflection is (15)(24)(67); and the
rotation is (15)(26)(47). Each of these fixes at least one edge. Our cycle
index is 14 (z17 + z13 z22 + 2z11 z23 ). This gives us C(k) = (k 7 + k 5 + 2k 4 )/4 ways
to color the edges with k colors. Notice that this answer is just k 2 times the
result for the previous example.
We can now easily find the number of non-equivalent ways to color (using k
colors, for any positive integral value of k) a figure with its symmetry group.
This does not allow us to count the number of non-equivalent colorings subject
to specific restrictions, however. In particular, we might ask how many ways
there are if each of the k colors must be used at least once; how many ways
there are if we must use more of one color than another; and so forth. These
questions require a little more effort, but can still be addressed through a
slight modification of the technique.
Suppose we are going to color with k colors; we introduce variables d1 , d2 ,
. . . dk . If we take the cycle index C(z1 , . . . zn ) and replace each variable zi
with the expression di1 + di2 + · · · + dik , the result is a new polynomial in the
variables d1 , . . . dk . We denote this function by Ĉ.
Example 8.17: Color the corners of the square of Figure 8.1 with two
colors, red and blue (using variables r and b).
We will use D4 for the group; that is, two colorings are equivalent if there
is a permutation in D4 that maps one to the other. As we calculated earlier,
Symmetries and the Pólya–Redfield Method 157
our cycle index is C(z1 , z2 , z3 , z4 ) = (z14 + 2z4 + 3z22 + 2z12 z2 )/8. Substituting
zi by ri + bi gives us
Ĉ(r, b) = (r + b)4 + 2(r4 + b4 ) + 3(r2 + b2 )2 + 2(r + b)2 (r2 + b2 ) /8.
Together[Expand[%]]
The first line defines the cycle index as chr; at the end of the line, using
Shift+Enter causes Mathematica to evaluate the expression and it will recog-
nize the function chr[z1, z2, z3, z4] as defined. So, for instance, entering
chr[3,3,3,3] and Shift+Enter will give the number of non-equivalent ways
to color the corners with three colors.
The second line outputs the expression for Ĉ as a function of d1 through
d4 , but not in an easily readable form. The third line causes Mathematica to
expand the powers and collect like terms so that we may read the result. The
output (again, we end each line with Shift+Enter) is:
chr := (z1,z2,z3,z4)->(z1^4→+2z4+3z^2→+2z1^2→z2)/8→
expand(%)
Exercises 8A
1. Find the multiplication table of C5 , given ρ = (12345).
2. Find the two-row form of the permutation on five letters whose cycle
form is:
(i) (15)(234)
(ii) (1245)
3. Find the cycle form of the permutation whose two-row form is:
1 2 3 4 5
(i)
3 5 1 2 4
1 2 3 4 5
(ii)
2 5 4 1 3
Exercises 8B
1. Find the multiplication table of D3 , the symmetries of an equilateral
triangle with vertices 1, 2, and 3.
2. Find the two-row form of the permutation on six letters whose cycle
form is:
(i) (123)(456);
(ii) (23)(45).
3. Find the cycle form of the permutation on six letters whose two-row
form is:
1 2 3 4 5 6
(i) ;
4 5 6 3 2 1
1 2 3 4 5 6
(ii)
6 5 4 3 2 1
160 Introduction to Combinatorics
Problems
Problem 7: A student wrote |G/[c1 ]| instead of |G| / |[c1 ]|, based on the
identity |a| / |b| = |a/b| taught in algebra. The algebra book notwithstanding,
the student’s teacher took off many points! Explain.
Problem 8: We are to color a square with a color in each corner and a color
in the center; two colorings are equivalent if one may be moved into another
by rotations of 90◦ (corresponding to the group C4 ). How many distinct
colorings are there with k colors? Notice that even though this group looks
like C4 , it acts on five points. How many colorings are there if we only color
the corners? Can you find a relationship between the solutions to these two
problems?
Problem 9: We wish to color a 3×1 rectangle so that each of its 1×1 squares
is given a color. Colorings are equivalent under a rotation of the rectangle
by 180◦. Determine the number ck of ways to do this with k colors. Now
use the methods of Chapter 6 to find the generating function of ck . Use the
denominator of this generating function to find a recurrence relation for ck .
Problem 11: A regular tetrahedron is a solid with four faces, each an equi-
lateral triangle. It has four corners which we label 1, 2, 3, and 4, and six
edges. The group of symmetries of the tetrahedron has 12 elements. These
include α = (234), β = (134), γ = (124), and δ = (123); the squares of these
elements; three other elements produced by products of these; and of course
the identity. Find all twelve symmetries as permutations of the corners; find
the cycle index of the tetrahedron. Now find an expression for the number of
ways to color the corners of the tetrahedron with k colors.
Problem 13: We wish to color the circles on the square shown in Figure 8.5.
Find the cycle index using the group C4 (rotations but no reflections). If you
have access to a computer algebra program, find Ĉ(r, b) for the two-colorings
of the figure.
162 Introduction to Combinatorics
1 2 3
4 5
6 7 8
Problem 14: Find the cycle index for Figure 8.5 using the group D4 (all
rotations and reflections). If you have access to a computer algebra program,
find Ĉ(r, b).
Problem 15: Generalize the exercises to find the number of ways to k-color
the corners of the regular polygon with p sides (where p is an odd prime)
where colorings are equivalent under the group Cp . Repeat using the group
Dp to allow reflections.
Problem 16: Find the number of ways to k-color the corners of a regular
polygon with 2p sides, where p is an odd prime, and colorings are equivalent
under the cyclic group C2p . Repeat using the group D2p to allow reflections.
Chapter 9
Partially Ordered Sets
9.1 Introduction
The first objects that we encounter in mathematics are ordered; that is,
given (for instance) two different integers, we know that one of them must
be larger than the other. Later in mathematics, we find objects that are
not ordered in the same way; for instance, there are two different groups of
order four, and it makes no sense to say that one of them is “bigger than” or
“comes before” the other. Between these two extremes, there are collections
for which it is possible to make a sensible statement that some members of the
collection are bigger or smaller than others, but for other pairs of members,
no comparison is possible. Such a collection of objects, together with the
appropriate definition of “bigger than,” is called a partially ordered set, or
poset for short.
More rigorously, a partially ordered set is a set S together with a relation
≺ that is irreflexive, antisymmetric, and transitive (see Appendix A to review
these terms). We may also use the relation , which is reflexive, antisymmet-
ric, and transitive; it is understood that that a b means “Either a ≺ b or
a = b.” Either way, the relation is called a partial order on S. If the poset
has the property that any two elements x and y are related or comparable
(that is, either x ≺ y or y ≺ x), we say it is a total order , and refer to it as
“an ordered set.” A poset that is not a total order has at least one pair of
elements that are incomparable, i.e., there are x and y in the poset for which
neither x ≺ y nor y ≺ x is true. We write xky to indicate that x and y are
incomparable. Since the usual sets of numbers N, Q, R and Z are ordered sets,
we see that a partially ordered set is merely a generalization of these familiar
objects.
A poset is said to be locally finite if, for any comparable pair x ≺ y there
are only finitely many z satisfying x ≺ z ≺ y. Thus, N and Z are locally
finite; Q and R are not. If x ≺ y but there is no z for which x ≺ z ≺ y, we
say that y covers x. If the poset contains one or more elements x with the
property that x 6≺ z for any z, this element x is a maximum element of the
poset; similarly, if there is no z with z ≺ x, then x is a minimum element of
the poset.
163
164 Introduction to Combinatorics
All All
All
Another common family of posets comes from group theory. Given a group
G, we can consider its collection of subgroups ordered by containment. That
is, if G1 and G2 are subgroups of G, we say G2 ≺ G1 if G2 is a subgroup of G1 .
We illustrate with the Hasse diagram of the subgroups of Z12 in Figure 9.2.
All
AllAll All
All
All
All
Proof. We will prove there exists a maximal element, and leave the proof
of a minimal element to Problem 1. Choose an element x1 ; if there is no
element greater than it, it is maximal and we are done. Otherwise, find x2
with x1 ≺ x2 ; if there is no element greater than x2 , we are done. Continue
this process; it must terminate, as there are only finitely many elements in
the poset. When it terminates, we will have found a maximal element.
The theorem is easily seen to be false for infinite posets; consider, for in-
stance, the set of all integers with the usual order. A poset without a maxi-
mum or a minimum element is shown in Figure 9.4.
All All
All All
Proof. We will prove the associative law for the join and leave the others
to exercises. Because we are dealing with a lattice, we know that any two
elements have a meet and a join, so there is no question that both sides
of the equation are defined; we merely need show that they are equal. Let
x = a ∧ (b ∧ c) and y = (a ∧ b) ∧ c. By definition, we see x a and x (b ∧ c),
so x b and x c. Now a ∧ b is the least element w for which w a and
w b, so x (a ∧ b). (It is not possible for x and w to be incomparable, for if
this were so, a and b would not have a unique least upper bound.) It follows
that x (a ∧ b) ∧ c = y. An exactly similar proof shows that y x as well;
because the partial order relation is irreflexive, we must have x = y.
Proof. Given the finite lattice, we know from Theorem 9.1 that there is at
least one minimal element and one maximal element. Take such a minimal
element, which we will call 0̄. If x is any other element of the lattice, find
0̄ ∧ x = z. By definition, z 0̄, which means (since 0̄ is minimal) that z = 0̄.
Since 0̄ ∧ x = 0̄, by Theorem 9.2(5), we have 0 x. Thus 0̄ is the unique
minimum element. The existence of the unique maximum element is similar.
A lattice is said to be distributive provided that meet and join each dis-
tribute over the other; that is, that
a ∧ b ∨ c = (a ∧ b) ∨ (a ∧ c) and a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c).
We know from set theory (see Appendix A) that union and intersection
of sets distribute in this way, so that every subset lattice is a distributive
lattice. Not every lattice is a distributive lattice; see, for instance, the lattice
in Figure 9.5.
All
All
the two. Clearly, any two total orders on n elements are isomorphic; other
isomorphisms are explored in the exercises.
Example 9.1: Find an isomorphism between the poset D12 and the poset
of submultisets of the multiset {a, a, b}.
We see from the Hasse diagrams that these appear to be isomorphic. Create
an isomorphism by mapping each occurrence of a in a submultiset to a factor
of 2 in a divisor of 12, and each b to a factor of 3. Thus {a, b} corresponds to
6, {a, a} to 4, and so forth. We can easily confirm that this is an isomorphism.
Clearly, if two posets have the same Hasse diagram (apart from the labels on
the vertices), they are isomorphic; we must be very careful, however, with the
converse. For instance, consider the two posets of the diagram in Figure 9.6.
The two graphs are isomorphic as graphs, but considered as directed graphs
with edges oriented downwards, they are different, and represent different
posets.
Given two posets X and Y , there are a few ways of constructing other
posets from them. The simplest way is perhaps the direct sum. This is
denoted X + Y and is defined on the set X ∪ Y ; we say a ≺ b in X ∪ Y if a ≺ b
in X, or a ≺ b in Y , and any element of X is incomparable to any element in
Y . The Hasse diagram of X + Y is the disjoint union of the Hasse diagrams
of X and of Y , respectively.
The Cartesian product of X and Y is the poset on the set of ordered pairs
{(x, y) : x ∈ X, y ∈ Y } in which (x1 , y1 ) ≺ (x2 , y2 ) whenever x1 ≺ x2 in X
and y1 ≺ y2 in Y .
Example 9.2: Find the Cartesian product of the poset B1 × B1 .
Recall that B1 is the poset whose Hasse diagram consists of two vertices
and a single edge; we may think of the elements of B1 as {1} and {} = ∅.
170 Introduction to Combinatorics
FIGURE 9.6: Two posets with almost the same Hasse diagram.
Then the product has four elements; they are ({1}, {1}), ({1}, ∅), (∅, {1}),
and (∅, ∅). We show the Hasse diagram of this poset below, next to the poset
of B2 for comparison purposes.
AllAll All
All All
There are several ways to prove this theorem, some more involved than
others. Our proof below is adapted from that of Marshall Hall ([50]).
Proof. We use induction on the number n of elements of X; if n = 0 or
n = 1, the result is trivial. We therefore take n to be greater than 1 and
assume the truth of the Theorem for any poset with fewer points. Suppose
we find a maximal chain C of our poset (where by maximal we mean that the
addition of any element to C makes it no longer a chain). Consider the poset
X ′ obtained from X by removing the elements of C; if X ′ has width no more
than a − 1, we apply the induction hypothesis to X ′ to cover it in a − 1 chains,
replace the chain C, and we are done. Therefore, we must assume that C does
not include any point from some antichain Y = {y1 , y2 , . . . ya }. Define the
down-set generated by Y to be Y − = {x ∈ X : x yi for some 1 ≤ i ≤ a};
the set of all elements of X that are “smaller” than some element of Y .
Similarly, Y + = {x ∈ X : yi x for some 1 ≤ i ≤ a} is the up-set generated
by Y . Notice that if there is any element of X not contained in Y − ∪ Y + , we
could add this element to Y to make a larger antichain; as Y was a maximal
antichain, this is impossible, so Y − ∪ Y + = X, and Y − ∩ Y + = Y .
At this point, the idea is to say that Y − is a poset that is smaller than X,
and has width a, so by the induction hypothesis it can be partitioned into a
chains; and Y + is a poset that is smaller than X, so it may be partitioned
similarly. Now, we “glue” together the chains in Y + to those in Y − by the
element of Y that they have in common; so the chain in Y + for which yi is the
least element will join to the chain of Y − for which yi is its greatest element,
for every 1 ≤ i ≤ a. How can this fail?
It can fail rather easily, in fact. For instance, Y + might be the entire poset,
because Y could be the set of all minimal elements, or of all maximal elements.
In this case the induction hypothesis would not apply. (The largest antichain
174 Introduction to Combinatorics
consisting of minimal elements must consist of all the minimal elements, and
similarly for the maximal elements; see the Exercises.) However, if Y consists
neither of all maximal elements nor all minimal elements, the proof is finished.
So assume that Y consists entirely of maximal elements (if Y consists of
minimal elements, we will turn the poset upside-down, partition it into chains,
and then turn it right side up again). Find a minimal element x1 with y1 ≺ x1 ;
that is, follow any chain from y1 downward as far as possible and give the
minimal element of that chain (which must be minimal in the poset) the label
x1 . Now we have a chain C1 ; look at the poset X \ C1 . What is the width of
this poset?
We claim now that X \ C1 has width at most a − 1. We have already
established that every largest antichain is either the set of all maximal or
of all minimal elements; C1 contains one of each, so we have removed one
element from each antichain of size a. Now the induction hypothesis applies,
and we may partition X \ C1 into a − 1 chains. Throw the chain C1 back in,
to find a partition of X into a chains, and we are done.
Dilworth’s theorem is useful for a number of purposes, not least of which
is that it provides a fairly short proof of Philip Hall’s theorem (Theorem 1.2)
which we give here, along with the statement of the theorem:
A collection D of sets has a system of distinct representative if and only if
it never occurs that some n sets contain between them fewer than n elements.
Proof. Let D = {B1 , B2 , . . . , Bk } containing among them v elements {1, 2,
. . . , v} and suppose that any union of n of these sets contains at least n
elements. We form our poset P on the elements B1 , B2 , . . . , Bk , 1, 2, . . . , v
and we rule that i ≺ Bj if and only if i ∈ Bj ; D is an antichain, as is
the set {1, 2, . . . v}. However, these may not be the maximum antichains.
An antichain of largest cardinality might consist of some of the elements
and some of the sets. By renumbering if necessary, let the largest antichain
be 1, 2, . . . ℓ, B1 , B2 , . . . Bf ; here we note that ℓ + f ≥ v ≥ k because this
largest antichain must be at least as big as the antichain D and the antichain
{1, 2, . . . , v}. Because this is an antichain, no element below ℓ + 1 may belong
to any Bi for i ≤ k, so we have B1 ∪ B2 ∪ . . . ∪ Bf ⊆ {ℓ + 1, ℓ + 2, . . . , v}. By
our hypothesis, this union contains at least f elements, so we have f ≤ v − ℓ.
Use Dilworth’s theorem to partition our poset into ℓ + f chains. We can
again renumber our sets and elements so that the chains look like
Exercises 9A
1. Find the Hasse diagram for the poset D36 .
2. Find the Hasse diagram for the poset of the multisubsets of the multiset
{a, a, b, b}.
3. Prove that meet and join commute (Theorem 9.2(2)).
4. Prove the idempotent laws for meet and join (Theorem 9.2(3)).
5. Prove that a ∧ b = a if and only if a b.
6. Illustrate Theorem 9.4 by assigning sets to each element of the poset of
Figure 9.4 so that it is ordered by inclusion.
7. Show that the largest antichain consisting only of minimal elements
must consist of all the minimal elements.
8. Find all minimal elements of the poset of Figure 9.8.
9. Find the width of the poset of Figure 9.8.
All All
All All
Exercises 9B
1. Find the Hasse diagram for the poset D60 .
2. Find the Hasse diagram for the poset of the multisubsets of the multiset
{a, a, b, c}.
3. Prove the associative law for the join (Theorem 9.2(1)).
4. Prove the absorption laws for meet and join (Theorem 9.2(4)).
5. Prove that a ∨ b = b if and only if a b.
6. Illustrate Theorem 9.4 by assigning sets to each element of the poset of
Figure 9.5 so that it is ordered by inclusion.
7. Show that the largest antichain consisting only of maximal elements
must consist of all the maximal elements.
8. Find all maximal elements of the poset of Figure 9.8.
9. Find the height of the poset of Figure 9.8.
Problems
10.1 Degrees
Recall the definitions of graphs from Section 1.1.4. The degree of the vertex
x was defined to be the number of edges that have x as an endpoint. We write
degG (x) for the degree of x in graph G, or simply deg(x) if only one graph is
being discussed. A graph is regular if all vertices have the same degree, and in
particular a regular graph of degree 3 is called cubic. We denote the smallest
of all degrees of vertices of G by δ(G), and the largest by ∆(G).
The degree sequence of a graph consists of all the degrees of the vertices.
For example, degree sequence (4, 2, 2, 1, 1, 0) corresponds to the graph
0 2 1
2 4 1
(Degrees are shown next to the vertices.) We normally write such a sequence
in non-ascending order.
It is interesting to ask whether a given sequence is the degree sequence of
any graph. If so, the sequence is called graphical ; a graphical sequence is called
valid if there is a connected graph with those degrees. Some sequences are
easily seen not to be graphical. Theorem 1.1 says that the sum of degrees in
any graph must be even, so the sum of the elements of any graphical sequence
must be even. Moreover, if a graph has d + 1 vertices with degree greater
than zero (non-isolated vertices), no vertex can have degree greater than d:
(3, 1, 0, 0) is obviously not graphical. (This last argument does not apply to
multigraphs.)
Example 10.1: Which of the following sequences are graphical: (3, 3, 1, 1, 0),
(3, 3, 2, 1, 1), (3, 3, 2, 1, 0)?
Suppose a graph has five vertices and two of them have degree 3. If those
two vertices are not adjacent, each must be joined to all three of the remaining
vertices (See the left-hand graph in Figure 10.1) so these all have degree at
177
178 Introduction to Combinatorics
least 2. Therefore the two vertices of degree 3 are adjacent. There are only
two possibilities: either both are adjacent to the same two vertices out of the
remaining three, or not. In the former case, both of those vertices have degree
at least 2 (it may be greater, if they are adjacent to each other or to the final
vertex), and this is not possible for any of the degree sequences given. So the
graph must look like the right-hand graph in the figure, possibly with other
edges between the lower vertices. This rules out the first and third sequences,
so they are not graphical; however, the middle sequence is graphical, and is
realized by the right-hand graph.
Of course, we know that the third sequence is not graphical, because the
sum of its elements is odd.
One way to construct a new graph from an old one is to add one vertex
and join it to some of the other vertices. The following theorem of Havel [53]
and Hakimi [49] essentially shows that this process can be reversed.
d0 ≥ d1 ≥ . . . ≥ dk ≥ dk+1 ≥ . . . ≥ dv ≥ 0,
Proof. Suppose you have a graph whose degree sequence is T . You can
construct a graph with degree sequence S by simply adding a new vertex and
joining it to the d0 vertices with degrees d1 − 1 to dd0 − 1. So the “if” part is
easy.
So let us assume S is graphical. Suppose there is a graph G whose vertices
x0 , x2 , . . . , xv−1 satisfy deg(xi ) = di for every i. For convenience we will call
x1 , x2 , . . . , xd0 the earlier vertices and xd0 +1 , . . . the later vertices.
Suppose the vertices of G can be ordered so that x0 is adjacent to each
of the earlier vertices. (Ordering would be relevant if there is more than one
vertex with degree d0 or more than one vertex with degree dd0 .) In that case
we shall say G is type I ; otherwise it is type II. If G is type I, simply delete
x0 and all the edges joining it, and you have a graph with degree-sequence T .
Now we assume G is type II. Then there must be some earlier vertices
xj that are not adjacent to x0 . Suppose there are t such vertices (t > 0),
Introduction to Graph Theory 179
⇒ = ⇒
a b c
p q
d e
could represent five camps denoted a, b, c, d, e and the walking tracks between
them; there are two tracks joining c to e, and they are labeled p and q,
and other tracks are denoted by their endpoints. (These representations are
ordered.) A sequence of vertices and edges of the form (. . . , x, xy, y, yz, z, . . .)
will be called a walk, because on the diagram it represents a trail that one
could walk among the camps.
Consider the following walks:
In the same way, one could argue that any closed walk contains a cycle, but
there is one exception to be made: it is possible to walk from x1 to xn and
then walk back by retracing your steps. The graph of such a walk will not
contain a cycle, unless the x1 -xn walk contained one. But any circuit must
contain a cycle.
182 Introduction to Combinatorics
We say two vertices are connected if there is a walk from one to the other.
(In view of Theorem 10.2, we could replace “walk” by “path.”) This gives us a
formal definition of connectivity: a graph is connected if and only if all its pairs
of vertices are connected. We can now define a component as the subgraph
formed by taking a maximal set of vertices with every pair connected, plus all
the edges touching them.
The distance between two vertices is the minimum length among the paths
joining them (or the length of the shortest path). The distance from x to y is
written d(x, y). For consistency we write d(x, x) = 0.
Example 10.4: Find the distance from x to each other vertex in the
following graph.
x a d
b c
a c
e
x f
b d
Vertex Neighbors
x = x0 a, b a = x1 d(x, a) = 1
d(x, x) = 0 b = x2 d(x, b) = 1
a = x1 x, c x already labeled
d(x, a) = 1 x c = x3 d(x, c) = 2
b = x2 x, c, d x already labeled
d(x, b) = 1 c already labeled
d = x4 d(x, d) = 2
c = x3 a, b, e a already labeled
d(x, c) = 2 b already labeled
e = x5 d(x, e) = 3
d = x4 b, e b already labeled
d(x, d) = 2 e already labeled
e = x5 c, d, f c already labeled
d(x, c) = 2 d already labeled
f = x6 d(x, f ) = 4
is not connected – to get from Alaska to the other states you need to cross
either Canada or the ocean. We say two countries or states are neighbors if
they have a border—a single common point does not count.
Given a map, we construct a graph as follows: the vertices correspond to
the countries (or states), and two vertices are adjacent when the two countries
share a border. It is always possible to draw this graph in such a way that
no two of the edges cross—the easiest way is to draw the graph on top of the
map, with each vertex inside the corresponding country. A graph that can be
drawn without edge crossings is called planar . So every map corresponds to
a planar graph. It is easy to draw a map from any given planar graph, so the
correspondence goes both ways.
Not all graphs are planar: try as you might, you cannot draw K5 without
crossings. On the other hand, some graphs are planar even though they do
not look that way. Figure 10.3 shows two representations of the same graph,
K4 . One has crossings, the other does not. Remember, we say the graph
is planar if it can be drawn in the plane without crossings, even though the
representation we are using has some crossings.
Suppose you want to print a map in an atlas. It is usual to use different
colors for the various countries. Some colors may be repeated, but the map
is easier to read if you avoid using the same color on two countries with a
common border. The corresponding problem in a graph is to label the vertices
in such a way that no two adjacent vertices receive the same label. The labels
are called colors, and a labeling is called a coloring of the graph, even though
the ideas can be applied to non-planar graphs, where the relationship to maps
does not exist. A coloring in which no two adjacent vertices receive the same
Introduction to Graph Theory 185
x y x
z t z t
Their proof was long, complicated and required extensive use of computers.
Later proofs include [88] and [46].
In a graph coloring, the set of all vertices receiving the same color is called
a color class. There are a number of applications of color classes outside
map printing (in fact, there is not much practical application of the four color
theorem to map printing.) For example, coloring is used in conflict resolution.
Example 10.6: A habitat zoo consists of several large habitats, each con-
taining several species. In such a zoo, you cannot put natural enemies to-
gether. Use graph coloring to design the zoo.
We form a graph whose vertices are the species to be housed in the zoo.
An edge means the two species are “enemies,” and cannot be housed in the
same habitat. Now color this graph. Two species can be put into the same
habitat if they receive the same color.
In this example we would like the number of habitats to be as small as
possible. So we want the number of colors to be as small as possible. We
define the chromatic number χ(G) of a graph G to be the smallest number of
colors possible for a proper coloring.
Another application is school timetabling. In this case the classes are rep-
resented by vertices, and an edge means that some student will be taking both
classes. Vertices in the same color class can be scheduled simultaneously.
186 Introduction to Combinatorics
The complete graph Kn has n vertices, and every pair is joined, so χ(Kn ) =
n. The cycle Cn has chromatic number 2 when n is even and chromatic number
3 when n is odd. The complete bipartite graph Km,n , which contains no odd
cycles, has chromatic number 2.
Obviously, if a graph is properly colored, every subgraph will also be prop-
erly colored. So, if G contains a subgraph Kn , its chromatic number will be
at least n. This gives us a tool to find chromatic numbers of small graphs:
find the largest complete graph that is contained in your graph. Color all
its vertices differently. Then try to color the remaining vertices using those
colors. Very often this is easy to do. If there is no complete graph, is there
an odd-length cycle? If so, at least three colors will be needed.
Another tool is:
The proof is a little difficult, and can be found in graph theory texts (for
example, [122, p. 980]).
We now present an easy algorithm that will always color a graph G in no
more than ∆(G)+1 colors—not the minimum, but close. Suppose the vertices
of G are x1 , x2 , . . . and the colors are c1 , c2 , . . . , c∆(G)+1 . Apply color c1 to
x1 . Then go through the vertices in order; when xi is to be colored, use cj ,
where j is the smallest positive integer such that cj has not yet been applied
to any vertex adjacent to xi .
Example 10.7: Apply the above algorithm to
x2 x3
x6
x1 x4
x5
The maximum degree is 3. We apply c1 to x1 . As x2 ∼ x1 we cannot use
c1 , and x2 receives c2 . The neighbors of x3 are x2 and x4 , so color c2 is the
only one barred (vertex x4 has not yet received any color); c1 is still free, so
x3 gets c1 . Similarly x4 gets c2 . Now x5 is adjacent to x1 (color c1 ) and x4
(color c2 ) so it receives c3 . Finally x6 is adjacent to all three colors, so it gets
c4 .
We could represent this coloring by
{x1 , x3 } ← c1 , {x2 , x4 } ← c2 , {x5 } ← c3 , {x6 } ← c4 .
As we said, this method does not necessarily return a minimal coloring; in
fact, the given graph has chromatic number 3, realized by
{x1 , x4 } ← c1 , {x2 , x5 } ← c2 , {x3 , x6 } ← c3 .
Introduction to Graph Theory 187
Exercises 10A
1. Prove that in any graph there must be two vertices with the same degree.
Show that this is not true for multigraphs, by exhibiting a multigraph
with degree sequence (3, 2, 1, 0).
2. Which of the following sequences are graphical? If the sequence is graph-
ical, draw a graph that realizes it.
(i) (4, 2, 2, 2, 1, 1) (ii) (5, 4, 3, 2, 2, 2)
(iii) (3, 3, 3, 3, 2, 2) (iv) (5, 3, 3, 3, 1, 1, 1, 0)
(v) (6, 5, 2, 2, 1, 1, 1, 0) (vi) (6, 5, 4, 3, 3, 3, 1, 1, 0)
d e f
4. Find the distance from x to each other vertex in the graph of the pre-
ceding exercise.
5. Find the distance from b to each other vertex in the following graphs.
b
(i) a b c d e (ii) a c d
k
w x y
v w x y z z
(i) (ii)
(iii) (iv)
(v) (vi)
Exercises 10B
1. Show that no cubic graph has an odd number of vertices.
2. A bipartite graph has 2n vertices. What is the maximum number of
edges it can have?
3. Which of the following sequences are graphical? If the sequence is graph-
ical, draw a graph that realizes it.
(i) (4, 4, 3, 3, 3, 1, 1, 0) (iv) (4, 3, 3, 2, 2, 2, 2)
(ii) (3, 3, 2, 2, 1, 1) (v) (7, 4, 2, 2, 2, 2, 1, 1, 1, 0)
(iii) (6, 5, 4, 2, 2, 2, 1, 0) (vi) (8, 5, 4, 3, 3, 3, 1, 1, 1, 1, 0, 0)
4. Show that there is no graph with degree sequence (4, 4, 4, 2, 2), but there
is a multigraph with this degree sequence.
5. Find all paths from a to d in the graph
a b c d
e f g h
6. Find the distance from c to each other vertex in the graph of the pre-
ceding exercise.
7. Find the distance from b to each other vertex in the following graphs.
(i) d (ii) b e
g
b
a c f h
a e h
c
f i
d g
10. The graph G contains at least two vertices. One vertex has degree 1,
and every other vertex has degree greater than 1. Show that G contains
a cycle.
11. Prove that any graph with v vertices and at least 1 + 21 (v − 1)(v − 2)
edges must be connected.
(i) (ii)
(iii) (iv)
(v) (vi)
Problems
R ≤ D ≤ 2R.
A A
B
B D
D
C
C
The problem was to find a walk through the city that would cross each
bridge once and only once, and visit all four parts. The only way to go
between the different pieces of land was to cross the bridges. In modern
terminology (terminology that would not have existed without Euler’s work!)
he observed that the city could be represented by a multigraph, with the parts
represented by vertices and the bridges represented by edges, as shown in the
second part of Figure 11.1. A solution to the problem would be a simple walk
in the multigraph that included every edge; even better would be a closed
simple walk, so that a person could start and finish from home.
Euler proved that no such walk is possible. But he did much more. He
essentially invented graph theory and showed how it could be used to represent
193
194 Introduction to Combinatorics
any set of islands and bridges, or indeed any set of towns and roads joining
them, and concocted an algorithm for traversability problems.
In graph terminology, we define an Euler walk to be a simple walk that
contains every edge of the network, and an Euler circuit to be a closed Euler
walk. A network that has an Euler circuit is called eulerian.
Suppose G has an Euler walk, and suppose X is a vertex of G. (So there
are d(X) bridges leading to the area X in the corresponding map.) Every
time the walk passes through X, you traverse two of these bridges. By the
end of the walk, this accounts for an even number of edges. The only way X
can have odd degree is if it is either the start or the finish of the walk. A walk
can have at most one start and one finish, so a network cannot have an Euler
walk if it has more than two odd vertices. Similarly, an eulerian graph must
have all its vertices even.
Euler showed [32] that these conditions are sufficient, if we add the obvious
proviso that the graph must be connected:
walk starting from b in the “remainder,” just as you did before. Then unite
the two walks as follows: at one place where the original walk contained c,
insert the new walk. For example, if the two walks are
x, y, . . . , a, b, c, . . . , x
and
b, s, . . . , t, b,
then the resulting walk will be
x, y, . . . , a, b, s, . . . , t, b, c, . . . , x.
(There may be more than one possible answer, if b occurred more than once
in the first walk. Any of the possibilities may be chosen.) The new walk is
a closed simple walk in the original network. Repeat the process of deletion,
this time deleting the newly formed walk. Continue in this way. Each walk
contains more edges than the preceding one, so the process cannot go on
indefinitely. It must stop: this will only happen when one of the walks contains
all edges of the original network, and that walk is an Euler walk.
The case where there are two odd vertices, say p and q, and every other
vertex is even, now follows very easily from the “all vertices even” case. Form
a new network by adding another edge pq to the original. The new network
has every vertex even, so you can find a closed Euler walk in it. Moreover, it
follows from the proof that you can choose p as the first vertex and the new
edge pq as the first edge. Then delete this first edge; the result is an Euler
walk from q to p.
E F G H
I J K L
First we check that the graph is connected and every degree is even. Then
select any starting vertex–A say–and trace a circuit at random, with the rules:
• You cannot use an edge twice;
• If you reach a vertex, you must continue if there is any edge touching it
that has not been used.
In the example, say we choose to go
(We omit the parentheses, and commas between the vertices, when no con-
fusion will arise.) We then have to stop because both edges touching A have
been used. Let’s call this the first circuit. Deleting its edges, we get
A B C D
E F G H
I J K L
We now start again from any one of the vertices that were touched in the
first circuit but still have edges in the above diagram. A good choice is F .
One possible circuit is
F JIEGDHGF.
Again you can go no further, E’s edges are used up. This is the second circuit.
Now combine the first and second circuits as follows: go along the first
circuit until you come to the first occurrence of F ; then go round the whole
of the second circuit; then finish the first circuit. In other words, replace the
first F in ABF CGKF EA by F JIEGDHGF : the result is
AB F JIEGDHGF CGKF EA
(where the space shows where we changed circuits; there isn’t really a gap
there).
All the edges in the second circuit are deleted, leaving
A B C D
E F G H
I J K L
and you look for another circuit in the remainder. In this case, starting at B,
you find the circuit (actually the whole thing)
BCGJKLCB.
A A
B
B D
D
C
C
Euler walks and their generalizations are used in what are called route
inspection problems. For example, suppose a highway inspector needs to drive
along and check all the main roads in an area. The road map can be translated
into a network G by interpreting all the intersections as vertices and the roads
as edges. Since the inspector does not want to cover the roads more than once
on each trip, and since he must start and finish from the city’s vehicle facility,
the most efficient route will correspond to an Euler circuit in G.
What if there is no such circuit? Then some of the roads must be traversed
twice. This is not allowed in an Euler circuit, so we add roads: for example, if
you need to travel the road from A to B twice, you represent that road by two
edges in the corresponding network. This process of adding duplicate edges
to make the network eulerian is called eulerizing the network. The minimum
number of edges needed to eulerize G is called the eulerization number of G,
and an efficient eulerization is one that uses that number.
There are two odd vertices, namely u and y. You would like to add an
edge from u to y, but this is not allowed: you must duplicate an edge that
is already present. So you try to find a solution that duplicates two edges.
Obviously one edge would need to touch u, and the other to touch y. There
are three possible solutions; one is to duplicate uv and vy.
As we said, you would prefer to add an edge uy. There are some situations
198 Introduction to Combinatorics
u w y
(ii) From an old vertex, if the edge just traversed was new, then turn around
and retake it;
If we treat this as a map with five countries, we get the map shown on
the left in Figure 11.5. However, we need to look at the outside boundaries,
corresponding to the ocean coast. This is handled by adding a sixth “country”
(or ocean) that encloses the other five. So we put in another vertex, connected
to all five, and look at the corresponding graph, shown on the right in the
figure. The question now asks, is there an Euler walk in this new graph? The
graph has two odd vertices, so the answer is “yes.”
200 Introduction to Combinatorics
(i) u v (ii) u v
w x y z w x y z
Proof. Suppose the theorem is not true. We can assume that all pairs of
nonadjacent vertices satisfy the given degree condition, and that if p and q
are nonadjacent vertices then the graph formed by adding edge pq, denoted
G+ pq, will be hamiltonian (if not, then join pq and use the new graph instead
of G). We would say G is maximal for the condition.
As v ≥ 3, Kv is hamiltonian, so G is not complete. Select two vertices, x and
y, that are not adjacent. Then G is not hamiltonian, but G∗ = G+xy is, so xy
must lie in every Hamilton cycle of G∗ . Trace such a cycle of the form (yx . . . y)
and delete the first edge; the result is a Hamilton path (x = x1 x2 . . . xv = y)
in G. If x ∼ xi for some i with 2 < i < p, then y 6∼ xi−1 , or else
(xxi xi+1 . . . yxi−1 xi−2 . . . x2 x)
would be a Hamilton cycle in G, which is impossible.
Say the neighbors of x are x2 , xj2 , xj3 , . . . , xjd , where 2 < j2 < j3 < . . . < jd
and d = deg(x). Then y is not adjacent to any of xj2 −1 , xj3 −1 , . . . , xjd −1 , or to
x. So there are d vertices not adjacent to y, and therefore deg(y) ≤ (v−1)−d =
v − d − 1. Therefore
deg(x) + deg(y)d + deg(y) ≤ d + v − d − 1 < v,
a contradiction.
This gives a sufficient condition, but it is not necessary; many hamiltonian
graphs do not satisfy the theorem. In fact, we know of no simple way to tell
whether a graph is hamiltonian. At first sight, the Euler circuit and Hamilton
cycle problems look similar, but there is a simple test to see whether a graph
is eulerian, and a straightforward algorithm to construct an Euler cycle when
it exists.
Often there are costs associated with the edges, such as airfares or travel
times. In those cases, we define the cost of a Hamilton cycle to be the sum of
the costs of the edges. These ideas were first studied in the 1930s by various
mathematicians. Whitney pointed out that the problem of finding the cheap-
est Hamilton circuit could be motivated as follows: A traveling salesman needs
to stop at several cities (ending back at home); find the shortest/cheapest
route that can be used. He referred to it as the Traveling Salesman Problem
or TSP. (For more history, see [98].) It is often sufficient to talk about the
TSP for complete graphs.
The obvious approach to the TSP is to list all possible Hamilton cycles and
work out the cost of each. However, this can be an extremely long computa-
tion. If there are n cities, there are n! different ways to order them. Clearly
202 Introduction to Combinatorics
(a, b, c, d) costs the same as (b, c, d, a), so you only need to check one in n
cycles, and the cycle gives the same result if you travel it in reverse order,
but this leaves (n − 1)!/2 essentially different cycles. Computer time will be
prohibitive, even for small cases. For example, if you process one hundred
routes per second, it will take more than 55 hours to examine every Hamilton
cycle in K12 . If you consider a salesman who needs to visit 30 or 40 cities,
the problem is far too large.
So we consider some algorithms that give an approximate solution. We’ll
look at two, the nearest neighbor algorithm and the sorted edges algorithm.
We usually assume our graph is a copy of Kn and there is a distance or cost
c(x, y) associated with each edge xy (the airfare, or distance, or whatever).
The algorithms can be applied to incomplete graphs, but there is no guarantee
that any cycle will be produced.
To explain the ideas behind the algorithms, suppose an explorer wants to
visit all the villages in a newly discovered area, and wants to do it as efficiently
as possible. The “costs” are the distances between settlements.
The sorted edges algorithm models the way she might proceed if she has a
map of the whole area, possibly produced by an aerial survey, with distances
marked. She might hope to find an efficient route by taking the shortest
feasible connections.
Sorted edges algorithm: Initially sort the edges from shortest (cheap-
est) to longest and list them in order. Select the shortest edge. At each stage
delete from the list the edge you just used, and any edges that would form a
circuit or if added to those already chosen, or would be the third edge cho-
sen that was adjacent to some vertex (we’ll call this a threeway), then select
the shortest remaining edge. In this case the result does not depend on the
starting point.
In the nearest neighbor algorithm, the explorer starts at one of the villages.
She asks the locals, “what is the nearest village to here?” If possible she goes
to that village next.
Nearest neighbor algorithm: First choose any vertex x1 as a starting
point. Find the vertex x2 for which c(x1 , x2 ) is smallest. Continue as follows:
at each stage go to the nearest neighbor, except that you never close off a cycle
(until the end) or backtrack. In other words, after xi is chosen (i < n), xi+1
will be the vertex not in {x1 , x2 , . . . , xi } for which c(xi , xi+1 ) is minimum.
Finally, xn is joined to x1 . Notice that the result of this algorithm depends
on the starting point.
In either example, it may be that two candidate edges have the same cost,
and either may be chosen. However, if the algorithms are to be implemented
on a computer, some sort of choice must be made. For your convenience in
working problems, let’s assume we always take the edge that occurs earlier in
alphabetical order (if edges bc and bd have the same length, choose bc).
Example 11.5: Figure 11.6 shows a copy of K4 with costs on the edges.
Apply the two algorithms to this graph.
Further Graph Theory 203
55
75 B 35
60 30
C 45 D
edge cost
BD 30
AD 35
CD 45
AB 55
BC 60
AC 75
Figure 11.7 shows all three Hamilton cycles in the copy of K4 , with their
costs. Note that the cheapest route, (A, B, C, D), cost 195, was not found by
either method. These algorithms are not guaranteed to give a perfect result.
But they give a good result in a reasonable time. They are more effective
for larger graphs. The examples in this book are all relatively small, so that
you can follow them, but in the real world you would not apply the nearest
neighbor or sorted edges algorithms to graphs like these.
As we said, either algorithm can be applied to graphs that are not complete,
but neither is guaranteed to give a result in that case. If the graph is close to
complete, the algorithms usually work, but not always.
Example 11.6: Find the routes generated by the sorted edges algorithm
and by the the nearest neighbor algorithm starting at each vertex, if possible,
in
204 Introduction to Combinatorics
A A A
55 55 55
75 B 35 75 B 35 75 B 35
60 30 60 30 60 30
C 45 D C 45 D C 45 D
ABCD (195) ACBD (200) ABDC (205)
u v w
4 9
8 7
5 9 8
9 9
4 6
x y z
The sorted edges algorithm gives the edges (in order) uv, xy, ux, yz, wz,
vw, forming a cycle uvwzyx of total cost 36 (which happens to be the cheapest
cycle possible). Now for nearest neighbor: Starting from u, we choose uv (the
cheapest edge from u), then vz (vu would be a repeat), then zy, then yx.
No further edge is available: xu makes a 5-cycle and xv makes a 4-cycle.
Similarly, starting from v we get the path vuxyz, and from x we get xyzvu,
neither of which can be completed. If we start at w, we get wzyxuvw, which
is the same cycle as we found by sorted edges, and from initial point z we get
the same answer. If we start from y, we get yxuvzw, of total cost 37.
On the other hand, if there are a number of pairs of nonadjacent vertices
(we say the graph is not very dense), a complete search may be feasible. We
give a technique for doing this at the end of the next section.
11.4 Trees
A tree is a connected graph that contains no cycles. Figure 11.8 shows
three examples of trees. Paths Pn and stars K1,n are other examples.
Further Graph Theory 205
LEMMA 11.3
An edge xy in a graph is a bridge if and only if it belongs to no cycle in the
graph.
Proof. Write G for the component of the graph that contains x and y. Delete
edge xy from G; call the resulting graph H.
(i) First assume xy is a bridge. Then H is not connected. So there are
two vertices in G, w and z say, that are not joined by a walk in H. But they
are joined by at least one walk in G. The only possibility is that xy was an
edge in every one of those walks. In particular, there is at least one walk of
the form wW xyZz in H, where W and Z are some strings of vertices. (If x
appears before y in every walk, we can swap labels w and z.)
Suppose xy is in a cycle in G, say xx1 x2 . . . yx. Even after the edge xy
is deleted, the path xx1 x2 . . . y is still in H, and there is a w-z walk in H,
namely
wW xx1 x2 . . . yZz.
But we said there was no such walk. This is a contradiction, so the cycle
could not have existed.
This proof is rather wordy and pedantic, but it becomes much clearer if
you look at Figure 11.9. In the left-hand diagram the heavy lines indicate the
walk that includes the edge xy, with the rest of the cycle shown in light dots.
w x y z w x y z
G H
FIGURE 11.9: Illustration of Lemma 11.3.
From part (ii) of the above proof we see that any graph with v vertices and
fewer than v − 1 edges cannot be connected.
COROLLARY 11.5.1
Any tree has at least two vertices of degree 1.
Proof. Say a tree has v vertices, of which u have degree 1. Every other vertex
has degree at least 2, so the sum of the degrees is at least u+2(v −u) = 2v −u.
There are v − 1 edges, so the sum of the degrees is 2v − 2. So 2v − u ≤ 2v − 2,
and u ≥ 2.
Trees can be used to enumerate things. One example is the use of trees to
find all Hamilton cycles in a graph.
Suppose we want to find all Hamilton cycles in a graph G. We use G to
construct a new graph, a tree, which we shall call T (G) or simply T .
Further Graph Theory 207
z u
First we select x as the starting point. There are three vertices joined to
x in G, namely y, z and u. So we start three branches, and label them as
shown.
x
y z u
A branch will go from y to vertices that we label z and v, but not to one
labeled x (because edge yx would be a duplication) or u (there is no edge yu
in G). Similarly there are two branches from each of the first level vertices
labeled z and u.
x
y z u
z v y u z v
We continue in this way. For example, the branch x, y, v can extend only to
u, because y would correspond to a repeated edge and v is not connected to x
or z. The branch x, z, u can extend only to v, because z would be a repeated
edge and x would form a small cycle.
208 Introduction to Combinatorics
y z u
z v y u z v
u u v v y y
v z u y v z
x x x x
So the example has two Hamilton cycles: xyvuzx and xzyvux. Each is rep-
resented twice.
ea are all joined by edges. If you need a path from a to e (for example, to
transmit a message between computers), you could use the single edge, or the
longer path a − b − c − d − e. So remove one edge from the cycle. The resulting
spanning subgraph is still connected. If it still contains a cycle, delete an edge
from it. Continue in this way: graphs are finite, so the process must stop
eventually, and you have a spanning tree.
Spanning trees are important for a number of reasons. A spanning tree
is a subgraph with a relatively small number of edges—and therefore easy
to examine—but it contains a significant amount of information about the
original graph. They have proven very useful in designing routing algorithms
and in a number of areas of network design. We shall touch on some of this
here, but for a more complete discussion please consult books on trees such
as [141].
Sometimes it is useful to know how many different spanning trees there are
in a given graph or multigraph. We’ll write τ (G) for the number of spanning
trees in G. Some cases are very easy: if T is a tree, then τ (T ) = 1; if G
is derived from a tree T by replacing one edge of T by a multiple edge of
multiplicity k, then τ (G) = k; the cycle Cn has τ (Cn ) = n.
Example 11.8: Count the number of trees in the following (multi)graphs:
a b a d
c
d c b e
G H
A 4-cycle abcd has four spanning trees, and three of them include edge ab.
Each of those will give rise to two trees in G, one for each of the edges from a
to b. There is one other (the path (bcda)). So τ (g) = 7. In H, each spanning
tree will consist of a spanning tree in cycle (abc) and a spanning tree in cycle
(cde). Each has three, so the combined graph has τ (H) = 3 × 3 = 9.
It is easy to work out τ (G) in small cases, but an algorithm is needed for
large G. If G is a graph or multigraph and A = xy is any edge of G, Gxy
(or GA ) is formed by deleting both x and y, inserting a new vertex A, and
replacing every edge zx and every edge zy by an edge from z to A. Gxy is
called the contraction of G by xy. We also define a (multi)graph G − xy (or
G − A), formed from G by deleting xy. Examples of these graphs are shown
in Figure 11.10.
τ (G) = τ (G − A) + τ (GA ).
210 Introduction to Combinatorics
x y xy
z t
G G – xy G xy
Example 11.9: Calculate τ (G − xy) and τ (Gxy ) for the graph G of Figure
11.10, and use this to find τ (G).
Every spanning tree of G − xy must contain edge yt, or else y will be
omitted. If neither edge xt is included, the other two edges must both be
used, and there is one such tree. Otherwise, there are two choices for the edge
from xt, and two choices for the edge to contain z (either xz or zt, but not
both). So there are four spanning trees with an xt edge, and five in all.
Similarly, for each edge from xy to t in Gxy there will be two spanning
trees, and there is one other, a total of seven.
So τ (G − xy) = 5, and τ (Gxy ) = 7, and τ (G) = 5 + 7 = 12.
Here are two multigraphs that are useful in counting spanning trees. An
n-fold path is formed from a path by replacing each edge with a multiple edge
of multiplicity n. An n-fold cycle is defined similarly. The number of spanning
trees in an n-fold path is
τ (nPv ) = nv−1
and the number of spanning trees in an n-fold cycle is
τ (nCv ) = vnv−1 .
The proof is left to Problems 11.10 and 11.11. Note that we are counting
all spanning trees, not just the number of isomorphism classes. For example,
K3 has three spanning trees, as the theorem says, but they are all isomorphic.
Example 11.10: Calculate τ (G), where G is the following graph. Check
your calculation by deleting and contracting a different edge.
(i)
=> ;
G G1 G2
=> ;
G2 G3 G4
(ii)
=> ;
G G5 G6
=> ;
G5 G7 G3
=> ;
G6 G8 G4
a 5 b
7 4
c 6 d
5 3
5 4
e g
6 f 4
(1) We start at a. The two possible edges are ab and ac. As ab is cheaper,
select y1 = ab.
(2) The only possible choices for the next edge are ac and bd, so the cheaper
one, bd, is chosen. T3 is the path abd.
(3) There are now four possible edges: ac (cost 7), cd (cost 6), df (cost 3) and
dg (cost 4), so the choice is df .
(4) Now there is a choice. The possible edges are ac (cost 7), cd (cost 6), cf
(cost 5), dg (cost 4), ef (cost 6) and f g (cost 4). Either dg or f g could be
used. Using alphabetical ordering, we choose dg.
(5) We have ac (cost 7), cd (cost 6), cf (cost 5) and ef (cost 6) (f g is not
allowed). The choice is cf .
(6) Finally, from ce (cost 5) and ef (cost 6) we choose ce.
The sequence of trees is
The first approximation is the K2 consisting of the edge of smallest cost. The
second approximation is formed by appending the next edge in the ordering.
At each stage the next approximation is formed by adding on the smallest
edge that has not been used, provided only that it does not form a cycle with
the edges already chosen. In this case the successive approximations are not
necessarily connected, until the last one.
In large graphs, the initial sorting stage of Kruskal’s algorithm can be very
time-consuming.
Exercises 11A
1. Are the following networks eulerian? If so, find an Euler circuit. If not,
what is the eulerization number?
(i) (ii)
(iii) (iv)
(v) (vi)
2. Are the graphs in Chapter 10, Exercise A.8 eulerian? If so, find an Euler
circuit. If not, what is the eulerization number?
Further Graph Theory 215
3. Draw the network of the following maze, and use it to solve the maze.
(i) (ii)
(iii) (iv)
c d
b e
a f
g h
216 Introduction to Combinatorics
10. In each part we show a graph labeled with the costs associated with
the edges. Find the costs of the routes generated by the sorted edges
algorithm and by the nearest neighbor algorithm starting at each vertex,
if possible.
Further Graph Theory 217
(i) u 5 v (ii) w 5 x
5 6 2 3
w x 6 7 8
6 8 7 4
y z
9
y 9 z
11. Show that the following graph has a Hamilton circuit, but that the
sorted edges algorithm fails and the nearest neighbor algorithm fails for
every possible starting vertex.
s t u
5 2
4 3
6 6 4
7 7
4 2
v 4 6
w 5 5
x
y z
12. Show that there are exactly six non-isomorphic trees on six vertices.
13. Suppose a tree T has a vertex of degree n. Show that T has at least n
vertices of degree 1.
14. Verify the formulas for:
(i) the number of spanning trees in an n-fold path;
(ii) the number of spanning trees in an n-fold cycle.
15. Find minimal spanning trees in the following graphs.
(i) a b c (ii) a b
9 c
4
6 3 7 3 8 6 7
6
d 6 e f 6 d e
5 4
9 8 5 3
3
g h i f g h
5
(iii) a b c (iv) a b
6 5 3 5 4 5 8
3 6
c d e f
d e
3
9 3 8 4 3 6 5 8
6 4
5
f 4 g g h i j
7
4 6 3 4 2
h j k l
4 i 4
218 Introduction to Combinatorics
Exercises 11B
1. Are the following networks eulerian? If so, find an Euler circuit. If not,
what is the eulerization number?
(i) (ii)
(iii) (iv)
(v) (vi)
(vii)
2. Are the graphs in Chapter 10, Exercise 10B.12 eulerian? If so, find an
Euler circuit. If not, what is the eulerization number?
3. The graph G has precisely two vertices x and y of odd degree. A new
graph or multigraph H is formed from G by adding an edge xy. If H is
connected, prove that G is connected.
4. Draw the network of the following maze, and use it to solve the maze.
Further Graph Theory 219
(iii) (iv)
7. Show that the following graph contains a Hamilton path but no Hamil-
ton cycle.
(ii) ab = 23 ac = 30 ad = 27 ae = 28 bc = 34
bd = 29 be = 41 cd = 32 ce = 42 de = 37.
(iii) ab = 8 ac = 5 ad = 7 ae = 11 bc = 9
bd = 7 be = 8 cd = 11 ce = 9 de = 11.
(iv) ab = 34 ac = 37 ad = 32 ae = 45 bc = 29
bd = 34 be = 29 cd = 42 ce = 43 de = 39.
9. In each part we show a graph labeled with the costs associated with
the edges. Find the costs of the routes generated by the sorted edges
algorithm and by the nearest neighbor algorithm starting at each vertex,
if possible.
(i) u 9 v (ii) s t u
4 4
7 8 6 3
7 6
w x 5 2 3
9 1
9 5 4 7
4 6
v 3 w 5 x
y 9 z 7 4
y z
10. Verify the results of Example 11.3.
11. Show that it is possible to decompose K9 into four Hamilton cycles, no
two of which share an edge.
12. Show that a graph on v vertices that has no cycle is connected if and
only if it has precisely v − 1 edges.
13. Prove that a graph is a tree if and only if: it has no cycles, but if you
join any two nonadjacent vertices the new graph has exactly one cycle.
14. Find minimal spanning trees in the following graphs.
(i) a b 4 c (ii) a
7 b 12 c
9 5
6 5 7
9 8 13
d e f
3 16 11 8 f
7 6 d e
4 3 9 7
g h i g
5 h
12
(iii) b
a 7 5 c
3 6 4
d 8 e
9 8 6
f 4 g
8 6 5
h i 3 j
Further Graph Theory 221
(iv) 3
a b
5
2 7
c d e
5 4 5 f
4 8 6 9
h i
g 5 7 4 j
7 3
8 9
k l
15. Prove that if a connected graph is a tree then every vertex of degree
greater than 1 is a cutpoint, but the converse does not hold.
Problems
Problem 1: We did not mention loops in our discussion of Euler walks. How
would you treat them? What sort of road would translate as a loop?
Problem 2: The girth of a graph G is defined to be the length of the shortest
cycle in G. (The girth of a tree is either defined to be ∞ or else not defined.)
(i) Prove that if a regular graph of degree r has girth 4, then it has at least
2r vertices.
(ii) Prove that if a regular graph of degree r has girth 5, then it has at least
r2 + 1 vertices.
Problem 3: Draw a graph that has:
(i) An Euler circuit but no Hamilton cycle;
(ii) A Hamilton cycle but no Euler circuit;
(iii) Both an Euler circuit and a Hamilton cycle;
(iv) Neither an Euler circuit nor a Hamilton cycle.
Problem 4: The vertices of Kn are labeled 1, 2, 3, . . . , n, and edge xy has
associated cost x + y. Prove that the cost of every Hamilton cycle in this
graph is the same.
Problem 5: The graph G has 2n vertices, and every vertex has degree at
least n. Show that G is hamiltonian.
Problem 6: The graph Ka,b,c is defined to have three sets of vertices, of sizes
a, b and c, and two vertices are adjacent if and only if they are in different
sets.
222 Introduction to Combinatorics
(v − 2)!
.
(d1 − 1)!(d2 − 1)! . . . (dv − 1)!
Problem 11: Show that there are precisely v v−2 different spanning trees in
Kv .
Chapter 12
Coding Theory
Suppose you want to send an e-mail message to a friend. Your message may
be an ordinary string of English words, but your computer can only send
electronic messages. So a program is used to convert your words into a string
of instances of two states, “power on” and “power off.” For our convenience
let’s write 1 for “power on” and 0 for “power off”; your message no longer
looks like “Let’s meet for lunch,” but something like
100110110011000011011100010110011011100010110011011001001011000.
223
224 Introduction to Combinatorics
This method is useful when there is a way of checking with the sender: for
example, if the message was received as
you could say “I got the second through fifth words OK; would you repeat
the first?” But this is not useful for electronic communications, where a large
number of symbols are sent every second. In the next section we’ll look at a
way around this.
Another problem is that the method is useless if more than one error occurs
in a word. The same occurs in everyday English: if “ bive” contains two errors,
there are many more possibilities: “bone,” “bane,”, “brie,” and so on. There
is no solution to this problem. There are encoding methods that can detect
(and correct!) many errors, but it is always possible that more errors occur.
For example, in the photos sent back from space, there will be the occasional
small area where the image cannot be decoded.
A E A F
C C
B D B D
G
After the codeword is sent, the receiver, (decoder or decrypter ) must re-
construct the original message. Suppose a string of seven binary symbols is
received. The decoder assumes that at most one error has been made in the
encryption. If more than one error occurs in seven symbols, the wrong mes-
sage will be found. We have to assume that this will occur very infrequently.
(If errors are more common, other methods can be used.)
226 Introduction to Combinatorics
3 3
0 1 1 0 0 1
1 1
1 0 1 0
0 2 0
This decoding process is very simple when the Venn diagram is used. The
decoder fills in the diagram and puts the number of 1s next to each circle, as
shown on the left-hand side of Figure 12.2. The two top circles are odd; the
wrong symbol must be the one in the unique cell common to both of those
circles.
This process will always work. Provided there is at most one error, the
Venn diagram method will yield the correct codeword. Moreover, every binary
string of length 7 can be decoded by this method. We’ll prove this in the next
section.
Given two binary strings, we define the distance between them to be the
number of positions in which they differ. The minimum distance between
any two codewords in a code (that is, the smallest of all differences between
two codewords) is called the distance (or minimum distance) of the code.
The weight of a codeword is the number of 1s it contains. That is, it is the
distance from 000 . . . 00. The weight of a code is the minimum weight of all
its non-zero words (if 000 . . . is in the code, you don’t include it in calculating
the minimum weight). We use the notations d(x, y) for the distance between
binary strings x and y and w(x) for the weight of x. The weight and distance
of a code C are denoted w(C) and d(C). (The use of the same notation for
distance between strings and between vertices of a graph is quite intentional;
see Problem 12.7.)
Example 12.3: The (n+1, n) parity-check code was introduced informally
in Section 12.1. It has 2n codewords of length n + 1. The messages are the
possible binary strings of length n, with another symbol added at the end to
make the number of 1s even. What are the words of the (3, 2) parity-check
code? What is the minimum distance of this code?
The possible messages are 1 1, 1 0, 0 1 and 0 0, so the codewords are 1 1 0,
1 0 1, 0 1 1 and 0 0 0. By inspection, the code has minimum distance 2.
We’ll look further at parity-check codes in Example 12.3 and Exercise
12A.5.
Example 12.4: Here is a code with five words:
A = 1 0 1 0 1 0 1
B = 0 1 0 1 0 1 0
C = 1 1 1 0 0 0 0
D = 0 0 0 1 1 1 1
E = 0 0 0 0 0 0 0
228 Introduction to Combinatorics
The 16 words that can arise from Venn diagram encoding form a code of
length 7. If you check the table, you will see that the code has weight 3, and
in fact the minimum distance between words is 3. So this is a weight 3 code.
(At the moment, the easiest way to see this is to check all the pairs of words.
We’ll see an easier method in Section 12.4.)
Suppose a codeword x from this code is to be transmitted, and exactly
one error occurs. Let’s say the actual string received is y. Then the triangle
inequality tells us that the distance from y to any other codeword (other than
x) must be at least 2. So, if it is assumed that the number of errors is at most
1, then the correct message will be reconstructed. We express this by saying
that the Venn diagram code will correct any single error. It is called a single
error-correcting code.
In nearly all cases, decoding follows the rule that, if the received string is
not a word of the code, it is decoded on the assumption that the number of
errors was smallest possible. This is called nearest neighbor decoding.
Suppose a code has minimum distance d. If d or more errors are made when
codeword x is transmitted, it is possible that a different codeword could be
received, and the receiver would mistakenly assume that no error occurred.
However, this is impossible when the number of errors is smaller than d. In
that case the error would certainly be detected. If the number of errors is
smaller than d/2, nearest neighbor decoding will lead to the correct message.
These two facts are usually expressed as
(Of course, when d is even, this last number is rounded down to d/2 − 1,
because a fractional number of errors is meaningless.)
It follows from Theorem 12.2 that the Venn diagram method will correct
any single error in a word.
Example 12.5: The (n + 1, n) parity-check code was defined in Example
12.3. How many errors can it detect or correct?
The code has distance 2. Any single error can be detected, but no errors
can be corrected. (For example, if you receive 11100, you cannot tell whether
the original was 01100, 10100, 11100, 11110 or 11101.)
In constructing a block code with distance d, we must select a number of
codewords (binary strings) of length n such that every two words differ in at
least d places. We would like to find as many codewords as possible. What is
the maximum number? This problem is not completely solved, but there are
some useful results.
Example 12.6: What is the maximum number of words in a block code
with length 3 and distance 2?
We know that the (3, 2) parity-check code has length 3 and distance 2, and
this code has four words. Are five words possible?
Suppose we have such a set S of five words. Write S = S0 ∪ S1 , where Si
consists of the words starting with i. One of these must have at least three
elements; say it is S1 , and suppose S1 contains the distinct words 1 a b, 1 c d
and 1 e f . Then a b, c d and e f are distinct binary words each of distance 2.
But this would mean, for example, that a, c and e are all different, and this
is impossible since we only have two symbols to choose from.
0+0 = 0 0+1 = 1
1+0 = 1 1+1 = 0
0×0 = 0 0×1 = 0
1×0 = 0 1 × 1 = 1.
The join or bit sum or sum of two binary sequences is defined as follows:
the sum of individual entries is the sum in Z2 , as defined above, and to add
230 Introduction to Combinatorics
1 0 10 1 01 1
+ 1 1 1 0 0 0 1 0.
0 1 00 1 00 1
example is the code C = {0000, 1111}. If two errors are made, for example if
1010 is received, there is no reason to decode as 0000 or as 1111. We would
prefer a code that gives a unique solution under nearest neighbor decoding.
Proof. Write S for the set of all binary vectors of length n. For each codeword
a in in C, define S(a) to be the set of all members of S that are distance e
or less from a. Suppose x is a common member of S(a) and S(b). If message
x is received, we cannot tell whether the intended message was a or b. So in
this case the code cannot correct a transmission with e (or fewer) errors—a
contradiction. Therefore the sets C(a), for ainC, are all disjoint. There are ti
Pe
vectors distance precisely i from a, so |C(a)| = i=0 ti . There are n words
Pe
in C, so there are at least n i=0 ti binary vectors of length n. But there are
Pe n
precisely 2n such vectors. So 2n ≥ n i=0 ti , and n ≤ Pe2 t .
i=0 (i)
The inequality in Theorem 12.3 is called the Hamming bound after Richard
Hamming (See Appendix C).
A code C of N binary codewords of length t, of width d(C) = d = 2e + 1, is
called perfect if it meets the Hamming bound, that is
2n
n ≤ Pe t .
(12.1)
i=0 i
U = (A1 A2 A3 A4 A5 A6 A7 ).
HU T = (0 0 0)T .
Now suppose an error has been made, and the string W has been sent instead
of the codeword U . We call the difference, V = W − U (and because we are
working over zz2 , we could just as easily say V = W + U ), the error pattern.
When we test W we get
HW T = HU T + HV T = (0 0 0)T + HV T = HV T .
The useful property of the Venn diagram code is that, if we assume there is
at most one error, HV T tells us exactly which symbol was wrong.
In order to generalize this, we look at the columns of H. If we translate the
columns into numbers by making column (a b c)T correspond to the integer
4a+ 2b + c, each of 1, 2, 3, 4, 5, 6, 7 occurs precisely once. We say that (a b c)T
is the binary column representation of a + 2b + c, the representation in base 2
written as a column (with leading zeroes when necessary). Moreover, the last
three columns—the columns that correspond to the check digits—represent
1, 2 and 4, the first three powers of 2.
Coding Theory 233
and HU T = 0 is
u4 + u5 + u6 + u7 = 0,
u2 + u3 + u6 + u7 = 0,
u1 + u3 + u5 + u7 = 0.
u4 = u5 + u6 + u7 ,
u2 = u3 + u6 + u7 ,
u1 = u3 + u5 + u7 .
the column is the binary column representation of j, then the error was in
position j of the received word, and can be corrected immediately.
The code we have constructed is called a (2n − 1, 2n − 1 − n)-Hamming
code. These codes were first discovered by Richard Hamming. The Hamming
codes are perfect single-error-correcting linear codes. So there is a perfect
single-error-correcting code of length 2n − 1 for positive integer n ≥ 2. (When
n = 1, the message has length 0, so it has no content.)
Example 12.9: Describe the (3, 1)-Hamming code.
This is the case n = 2. The encoding matrix is
01 1
H=
10 1
and the two possible messages are 0 and 1. 0 encodes as 0 0 0 and 1 encodes
as 1 1 1.
The Venn diagram code is essentially the (7, 4)-Hamming code, with the po-
sitions in the codeword permuted to make encoding and decoding by diagram
easier.
a change will produce a codeword. If you were the contestant wearing the
hat that corresponded to that position, you would know the color of your hat:
your reasoning would be something like, “If my hat were red, our string would
be a codeword, and we decided that isn’t going to happen.” In that case you
would know that your hat was black. Of course, your assumption (that the
string is not a codeword) might be wrong, and you would lose. But only two
of the eight possible strings are codewords, so you would win the game in two
out of every eight cases, or 75% of the time.
This same sort of reasoning applies whenever there is a perfect code avail-
able. So, if n is any positive integer greater than 1, the (2n − 1, 2n − 1 − n)-
n
Hamming code can be used. There are 2[2 −1−n] codewords, and since they
n [2n −1]
are of length 2 − 1 there are 2 possible binary strings. If the hat colors
are chosen at random (as is true of the Hat Game), the chance that the string
representing them will be a codeword is
n
2[2 −1−n] 1
= n,
2[2n −1] 2
so the probability that the strategy we described will be succesful approaches
1 as the number of players goes to infinity.
A J R
B K S
C L T
D M U
E N V
F O W
G P X
H Q Y
I Z
Exercises 12A
1. What is the distance between the following strings?
(i) 101110111 and 101100110
(ii) 10101010 and 01010101
(iii) 000010000 and 001010110
(iv) 0101101011 and 0011100110
2. Prove (Theorem 12.1) the triangle inequality for distance between binary
strings.
3. Consider the five-word code given in Example 12.3. How would you
interpret the following received messages, using nearest neighbor decod-
ing?
6. Show that there is a set of four binary strings of length 5 with minimum
distance 3. Is there such a set with five members?
7. Encode the following messages using Venn diagram coding.
Exercises 12B
1. What is the distance between the following strings?
(i) 101110101 and 101100110
(ii) 10101010 and 01100010
(iii) 000011100 and 001010100
(iv) 010110100101 and 101011100110
2. Consider a code consisting of eight words 00000000, 00101110, 01011100,
10111010, 11100101, 11001011, 01110011, 10010111. What are the
weight and distance of this code?
3. Encode the following messages using Venn diagram coding.
Coding Theory 239
Problems
Problem 3: Suppose you construct a code from the Venn diagram code
by adding an eighth symbol to each codeword so as to make the sum of the
symbols even. That is, if the code had an odd number of 1s, the last symbol
is 1; otherwise it is 0. How many errors can this code detect or correct?
Problem 4: You need to send messages in the five symbols A, B, C, D, E.
Among the possible messages, A occurs most often, B second most, then C,
then D, and E is least frequent. Devise a code that will make the average
length of messages as short as possible.
Problem 5: Prove that a code can correct n errors if and only if the minimum
distance between codewords is at least 2n + 1.
Chapter 13
Latin Squares
13.1 Introduction
“There are thirty-six military officers, six each from six different regiments.
The officers from any one regiment include one of each of six ranks (a colonel,
a lieutenant-colonel, a major, a captain, a lieutenant, and a sub-lieutenant).
They wish to parade in a square formation, so that every row and every
column contains one member of each regiment and one officer of each rank.
Is this possible?”
This problem fascinated Euler in the eighteenth century [33], but he could
not solve it. In fact, it was not until 1900 that Tarry [114] proved, by an
exhaustive search, that no solution was possible. (See Appendix C for biogra-
phies of Euler and Tarry.)
Suppose we are given an arrangement of the officers in which every row
and every column contains one representative of each regiment. It can be
represented as a 6×6 array; if the officer in row i, column j belongs to regiment
k, then the array has (i, j) entry k. For example, one possible arrangement of
thirty-six officers from regiments 1, 2, 3, 4, 5, 6 could be represented by
1 3 6 2 4 5
5 1 3 6 2 4
4 5 1 3 6 2
.
3 6 2 4 5 1
6 2 4 5 1 3
2 4 5 1 3 6
Euler discussed these arrays at length in [33], and gave (essentially) the
following definition:
Definition: A Latin square of side (or order ) n is an n × n array based on
some set S of n symbols (treatments), with the property that every row and
every column contains every symbol exactly once. In other words, every row
and every column is a permutation of S.
The arithmetical properties of the symbols in a Latin square are not relevant
to the definition, so their nature is often immaterial; unless otherwise specified,
241
242 Introduction to Combinatorics
1 2 3
1 2
1 2 3 1 .
2 1
3 1 2
There are Latin squares of side 3 that look quite different from the one just
given, for example
1 2 3
3 1 2 .
2 3 1
but this can be converted into the given 3 × 3 square by exchanging rows 2
and 3.
As we said, the arithmetical properties of the symbols are not considered in
the definition of a Latin square. However, many examples arise from simple
arithmetic and algebra.
Example 13.1: Use modular arithmetic to construct a Latin square of
order 5.
Consider addition modulo 5. If we write Z5 = {0, 1, 2, 3, 4} for the set of
integers modulo 5, the addition table looks like
0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
.
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
and if we delete the labels and the row and column corresponding to 0, we
obtain
1 2 3 4
2 4 1 3
3 1 4 2
4 3 2 1
which is called the core of the table. It is a Latin square, and symbol 0 never
occurs.
This construction is not available for all positive integers; for example,
replacing 5 by 4, the 0 occurs in an inappropriate place:
0 1 2 3
0 0 0 0 0 1 2 3
1 0 1 2 3 ⇒ 2 0 2 .
2 0 2 0 2 3 2 1
3 0 3 2 1
x ∗ u = y = v ∗ x.
244 Introduction to Combinatorics
13.2 Orthogonality
We now return to Euler’s problem of the 36 officers. As we said, the problem
cannot be solved. However, if we replace 36 by 9, and have three regiments
a, b, c with three ranks α, β, γ represented in each, there is a solution. An
example is
aα bβ cγ
bγ cα aβ .
cβ aγ bα
This array was constructed by superposing two 3 × 3 Latin squares, namely
a b c α β γ
b c a and γ α β .
c a b β γ α
The two squares have the following property: The positions occupied by a
fixed symbol in the first square form a transversal in the second square. (For
example, the positions containing a in rows 1, 2 and 3 contain α, β, and γ,
respectively in the second.) We say the second Latin square is orthogonal to
the first.
Definition: Suppose A and B are Latin squares of side n based on symbol
sets SA and SB , respectively. B is orthogonal to A (written B ⊥ A) if, for
every x ∈ SA , the set of n positions in A occupied by x contain every member
of SB .
It is clear that each member of SB will occur precisely once in the cells
occupied by a fixed element in A.
Equivalently, suppose we construct from A and B an n × n array (A, B) of
ordered pairs, where (x, y) occurs in position (i, j) if and only if x occurs in
position (i, j) of A and y occurs in position (i, j) of B, then B is orthogonal to
A if every possible ordered pair with first element in SA and second element
in SB occurs in the new array.
Proof. Suppose A and B are Latin squares of side n based on symbol sets SA
and SB , respectively, and B is orthogonal to A. Write SA = {x1 , x2 , . . . , xn ,
and select y ∈ SB . There is exactly one position in which A contains x1 and
B contains y (put x = x1 in the definition). There is also one position where
A contains x2 and B contains y (put x = x2 ). In this way we see that every
246 Introduction to Combinatorics
member of SA occurs once with y. This proof can be applied to every member
y of SB . So A is orthogonal to B.
The array formed by superposing two orthogonal Latin squares is sometimes
called a Graeco-Latin square. (In fact, the name “Latin square” comes from
Euler’s habit of using the Roman (that is, Latin) alphabet for the symbols
of a square; and when representing a pair of orthogonal squares, he used the
Greek alphabet for the second square, just as we did.) But it is more common
to speak of “a pair of orthogonal Latin squares,” and to use the symbols
{1, 2, . . . , n} for each. We have exhibited a pair of orthogonal Latin squares
of order 3, and stated that there is no pair of orthogonal Latin squares of
order 6. One can ask: for what orders do there exist a pair of orthogonal
Latin squares? Can we find three or more Latin squares that are mutually
orthogonal —each one is orthogonal to all the others?
Before we discuss this problem, we define a standardized Latin square to
be a Latin square whose symbols are the first n positive integers, and whose
first row is
1 2 3 ... n . (13.1)
If A is any Latin square, we can convert it to standardized form by renam-
ing the symbols. If A and B are orthogonal, we can assume that both are
standardized; we rename the symbols in each separately.
1 2 3 4 1 2 3 4 1 2 3 4
2 1 4 3 3 4 1 2 4 3 2 1
.
3 4 1 2 4 3 2 1 2 1 4 3
4 3 2 1 2 1 4 3 3 4 1 2
On the other hand, the theorem tells us only that N (6) ≤ 5, but we know
from Tarry’s result that N (6) = 1.
ahij = i + hj,
1 2 x y
A= B=
2 1 y x
The proof can be found in most books on design theory (such as [123]).
The history of this problem and its solution can be found in [39].
Further results are known. For example, many authors have contributed to
the proof that:
A proof appears in [123]. In general, for any given constant k there exists
a lower bound nk such that N (n) ≥ k whenever n > nk , but the only known
value is n2 = 6; we do not know N (10), so n3 may be either 10 or 6. For
the best known lower bounds on nk , as well as a table of the largest known
numbers of Latin squares of orders less than 10,000, see [22].
A Latin square with no orthogonal mate is called a bachelor square. We
already know of bachelor squares of sides 2 and 6. (In fact, any Latin square
of these orders must be a bachelor.) At side 3, there is no bachelor.
Norton [78] (see also [95]) listed the isomorphism classes of Latin squares
of side 7; there are 147 in all. There is one set of six mutually orthogonal
Latin Squares 249
squares (all six squares are isomorphic); no other set of three or more mutually
orthogonal square exists, and only five of the remaining classes contain squares
with mates. So there are 141 isomorphism classes of bachelor squares. This
led to speculation that bachelor squares might be very common, but empirical
evidence suggests that for orders larger than 7, almost all Latin squares have
mates. However, there are bachelor squares of all orders other than 3 and 7.
The proof for odd orders may be found in [72] and [124].
To discuss even orders we define a function
LEMMA 13.9
If T is a transversal in A, the sum of ∆A (i, j) over the entries aij of T is
1
2 n if n is even and 0 if n is odd.
Proof. Suppose cells (1, j1 ), (2, j2 ), . . . , (2t, j2t ) form a transversal. From
Lemma 13.9 X
∆A (i, ji ) = t.
However, aiji ≡ i + ji , so
X
∆A (i, ji ) ≡ 2(1 + 2 + . . . + 2t) ≡ 0 (mod 2t),
a contradiction.
Obviously these squares have no orthogonal mates.
We conclude this section by exhibiting some small examples of orthogonal
Latin squares whose orders are not prime powers.
250 Introduction to Combinatorics
1 2 3 4 5 6 7 8 9 X .
2 X 4 8 6 3 5 9 7 1
3 6 7 1 8 9 2 5 X 4
4 7 X 5 2 1 9 6 8 3
5 3 8 X 9 4 6 1 2 7
6 9 1 3 7 2 8 X 4 5
7 8 6 9 3 X 1 4 5 2
8 5 9 2 X 7 4 3 1 6
9 4 2 6 1 5 X 7 3 8
X 1 5 7 4 8 3 2 6 9
1 2 3 4 5 6 7 8 9 X E D
2 3 4 5 6 1 8 9 X E D 7
3 4 5 6 1 2 9 X E D 7 8
4 5 6 1 2 3 X E D 7 8 9
5 6 1 2 3 4 E D 7 8 9 X
6 1 2 3 4 5 D 7 8 9 X E
.
7 8 9 X E D 1 2 3 4 5 6
8 9 X E D 7 2 3 4 5 6 1
9 X E D 7 8 3 4 5 6 1 2
X E D 7 8 9 4 5 6 1 2 3
E D 7 8 9 X 5 6 1 2 3 4
D 7 8 9 X E 6 1 2 3 4 5
Each of the other squares is obtained from this by column permutation; the
four permutations give the following four first rows:
[1 7 9 3 8 2 X D 5 E 6 4 ],
[1 4 7 2 X D 3 9 6 5 8 E ],
[1 9 2 D 6 X 4 E 3 8 7 5 ],
[1 5 D E 3 8 9 7 X 2 4 6 ].
Latin Squares 251
[1 15 2 14 3 13 4 12 5 11 6 10 7 9 8 ],
[1 14 3 11 6 9 8 7 10 4 13 12 5 15 2 ],
[1 10 7 13 4 2 15 6 11 9 8 3 14 12 5 ],
[1 6 11 10 7 15 2 5 12 14 3 9 8 4 13 ].
In each square the later rows are formed by developing the first row modulo
15.
(1, 2, . . . , n) (13.3)
LEMMA 13.13
There exists a set of N (n) − 1 mutually orthogonal idempotent Latin squares
of side n.
Proof. If A and B are idempotent Latin squares, then the Cartesian product
of A and B is a transversal square. The proof now follows that of Theorem
13.6.
As a consequence of Theorem 13.8, we have:
Proof. The only case to be investigated is order 10. But the square of order
10 given in the preceding section is a transversal square and is orthogonal to
its transpose, so these two squares are a pair orthogonal idempotent Latin
squares of that order.
Latin Squares 253
1 2 3 4 5 6
4 5 6 1 2 3
2 3 1 5 6 4
5 6 4 2 3 1
3 1 2 5 6 4
5 6 4 3 1 2
Among partial Latin squares, the Latin rectangle is of special interest. A
Latin rectangle of size k × n is a k × n array with entries from {1, 2, . . . , n}
such that every row is a permutation and the columns contain no repetitions.
For example, the first k rows of an n × n Latin square form a Latin rectangle.
Clearly, k can be no larger than n.
The following important theorem is a consequence of the results on systems
of distinct representatives (SDRs), which we discussed in Section 1.1.5.
COROLLARY 13.17.1
If L is a Latin square of side s and n ≥ 2s, then there is a Latin square of
side n with L as a subsquare.
Proof. Say n = s + t. Define M to be the s × t array
s+1 s+2 ... s+t
s+2 s +3 ... s+1
M = . .. ..
..
. .
s+s s+s+1 ... s+s−1
with entries reduced modulo t, where necessary, to ensure that they lie in the
range (s + 1, s + 2, . . . , s + t). Write A for the array constructed by laying row
i of M on the right of row i of L, for 1 ≤ i ≤ s:
A= L M .
One can also ask whether or not a given array can be embedded in a Latin
square.
Example 13.3: In each case, can the given array be embedded in a 7 × 7
Latin square? If so, give an example.
1 2 5 6 7 1 2 5 6 7
5 1 2 7 3 5 1 2 7 3
A= 3 7 1 4 2 B= 3 7 1 4 2
2 5 6 1 4 2 5 6 1 4
6 3 4 2 1 7 3 4 2 1
We can assume the given array will appear in the top left corner of the
Latin square, if one exists. Symbols 1 and 2 appear five times each in A.
That means there can be only two more occurrences of each; the only way
will be for them to appear in the bottom right corner of the square, forming
a 2 × 2 subsquare. One example is
1 2 5 6 7 3 4
5 1 2 7 3 4 6
3 7 1 4 2 6 5
A= 2 5 6 1 4 7 3 .
6 3 4 2 1 5 7
4 6 7 3 5 1 2
7 4 3 5 6 2 1
13.5 Applications
Designing Experiments Using Latin Squares
Latin squares provide a model for experiments where there are several dif-
ferent factors. As an example, consider a motor oil manufacturer who claims
that using its product improves gasoline mileage in cars. Suppose you wish
to test this claim by comparing the effect of four different oils on gas mileage.
However, because the car model and the drivers’ habits greatly influence the
mileage obtained, the effect of an oil may vary from car to car and from driver
to driver. To obtain results of general interest, you must compare the oils in
several different cars and with several different drivers. If you choose four car
models and four drivers, there are 16 car-driver combinations. The type of
car and driving habits are so influential that you must consider each of these
256 Introduction to Combinatorics
Y1 Y2 Y3 Y4
X1 Z1 Z2 Z3 Z4
X2 Z2 Z1 Z4 Z3 .
X3 Z3 Z4 Z1 Z2
X4 Z4 Z3 Z2 Z1
For example, the cell in the row marked X2 and the column marked Y3
contains entry Z4 . This means, in the test drive when car X2 is driven by Y3 ,
oil Z4 is to be used. The diagram is a plan for 16 test drives, one for each
combination of car and driver. It tells us which oil to use in each case.
The array underlying the experiment is a Latin square, so each oil appears
four times, exactly once in each row (for each car) and also exactly once in
each column (for each driver). This setup can show how each oil performs with
each car and with each driver, while still requiring only 16 test drives, rather
than 64. If 64 test drives are available, one technique is to use a Latin square
to schedule 16 tests, and then running each test four times. This enables the
experimenters to make a more reliable estimate of the underlying variability
due to uncontrollable factors (sometimes called “error”), which improves the
statistical reliability of the experiment.
This technique can be used with any size Latin square. Suppose there are
three types of treatment, X, Y and Z, and each is to be applied at n levels
(X at levels X1 , X2 , . . . , Xn , and so on). An n × n Latin square provides n3
comparisons with n2 tests; if the (i, j) element is k, then treatment levels Xi ,
Yj and Zk are applied in one test.
Further savings can be achieved by using orthogonal Latin squares. In
the motor oil example, one might wonder whether automobile performance
depends on the type of roads. So four different test routes could be chosen:
one primarily urban, one about two-thirds urban and one-third interstate,
one two-thirds interstate and one all interstate. If these routes are denoted
T1 , T2 , T3 and T4 , then the following design allows us to test all pairs of levels
of the four factors in 16, rather than 256, tests:
Latin Squares 257
Y1 Y2 Y3 Y4
X1 Z1 T1 Z2 T2 Z3 T3 Z4 T4
X2 Z2 T3 Z1 T4 Z4 T1 Z3 T2 .
X3 Z3 T4 Z4 T3 Z1 T2 Z2 T1
X4 Z4 T2 Z3 T1 Z2 T4 Z1 T3
Golf Designs
We conclude with an application to tournament scheduling. The teams
representing 2n + 1 golf associations wish to play a round robin tournament.
There are 2n+1 rounds; each team serves as “host” for the one round in which
they do not play, and the n matches in that round are played (simultaneously)
on the course of the host team.
The teams wish to play 2n − 1 complete tournaments in such a way that
every pair of teams play exactly once on each of the 2n − 1 available courses.
(We shall call such an arrangement a golf design.) When is this possible?
This question arose in planning an actual golf tournament in New Zealand.
It was reported by Robinson [89], who pointed out that the problem of con-
structing one round robin is equivalent to finding an idempotent symmetric
Latin square; the square has (i, j) entry k, when i 6= j, if and only if i plays j
at k. So the whole problem is equivalent to finding 2n − 1 symmetric idempo-
tent Latin squares such that the 2n − 1 (i, j) entries cover {1, 2, . . . , 2n + 1}
with i and j deleted, for all i 6= j. He proved that case n = 5 has no solution
and exhibited a solution for case n = 7 (see Figure 13.1).
We can use a Steiner triple system of order v to construct a v × v Latin
square L = (lij ). We set lii = i for all i. If i 6= j, find the unique triple that
contains both i and j. If it is {i, j, k}, then set lij = k. The resultant square
L is idempotent and symmetric.
Tierlinck [115, 116] proved that if a golf design exists for order 11, then it
exists for all odd orders other than 5 and possibly 41. Subsequently, Colbourn
and Nonay [23] found an example of order 11, and recently Chang [20] has
constructed one of order 41. So the problem is completely solved.
To solve particular cases, one could try to construct symmetric idempotent
Latin squares cyclically. If the first row of such a square is 0, a1 , a2 , . . . , a2n
258 Introduction to Combinatorics
0 2 4 5 1 6 3 0 3 6 1 5 4 2 0 4 5 6 2 3 1
2 1 6 4 5 3 0 3 1 5 0 6 2 4 4 1 3 2 0 6 5
4 6 2 0 3 1 5 6 5 2 4 1 0 3 5 3 2 1 6 4 0
5 4 0 3 6 2 1 1 0 4 3 2 6 5 6 2 1 3 5 0 4
1 5 3 6 4 0 2 5 6 1 2 4 3 0 2 0 6 5 4 1 3
6 3 1 2 0 5 4 4 2 0 6 3 5 1 3 6 4 0 1 5 2
3 0 5 1 2 4 6 2 4 3 5 0 1 6 1 5 0 4 3 2 6
0 5 3 2 6 1 4 0 6 1 4 3 2 5
5 1 4 6 3 0 2 6 1 0 5 2 4 3
3 4 2 5 0 6 1 1 0 2 6 5 3 4
2 6 5 3 1 4 0 4 5 6 3 0 1 2
6 3 0 1 4 2 5 3 2 5 0 4 6 1
1 0 6 4 2 5 3 2 4 3 1 6 5 0
4 2 1 0 5 3 6 5 3 4 2 1 0 6
0 a1 a2 a3 ... a2n
a2n + 1 1 a1 + 1 a2 + 1 ... a2n−1 + 1
.
a2n−1 + 2 a2n + 2 2 a1 + 2 ... a2n−2 + 2
... ...
2 5 9 14 16 13 15 12
3 1 10 12 11 15 4 13
4 7 12 2 13 16 1 14
5 8 2 13 15 1 14 11
6 9 15 3 1 14 11 10
7 16 13 8 3 11 2 9
8 14 16 9 6 5 10 2
9 4 14 16 10 7 3 6
10 13 4 7 2 12 5 16
11 15 7 5 14 8 6 3
12 10 5 1 4 9 13 15
13 6 8 15 7 3 16 1
14 11 1 6 8 10 12 7
15 3 11 10 12 5 9 4
16 12 6 4 9 2 8 5
(reduced mod 2n + 1). Moreover, you may as well fix ai1 to be i + 2. Then
properties (c) through (e) restrict the search considerably.
No solutions exist for 2n + 1 = 5, 7 or 11. It is found that there is a unique
solution for 2n + 1 = 9, and exactly four solutions exist for 2n + 1 = 13.
A solution for 2n + 1 = 17 is illustrated in Figure 13.2. Only columns 1
through 8 of A are shown. Column 0 consists of all zeros; columns 9 through
16 are derived from columns 8 through 1 by adding (9, 10, 11, 12, 13, 14, 15, 16)
modulo 17.
Exercises 13A
1. Write down the Latin square derived from the addition of integers mod-
ulo 6.
2. Verify that the multiplication table of integers modulo 6 does not pro-
duce a 5 × 5 Latin square.
260 Introduction to Combinatorics
3. A reduced Latin square of side n is one in which the first row and first
column are (1, 2, . . . , n) in that order.
(i) Prove that every Latin square is equivalent to a reduced Latin
square.
(ii) Say there are rn different reduced Latin squares of side n. Prove
that the number of Latin squares of side n is
n!(n − 1)!rn .
8. Without using the result of Theorem 13.17, prove directly that any
(n − 1) × n Latin rectangle can be completed to give an n × n Latin
square.
9. Use SDRs to complete the following Latin square.
1 2 3 4 5
5 1 2 3 4
4 5 1 2 3
10. In each case, can the given array be embedded in a 6 × 6 Latin square?
If so, give an example.
1 5 3 4 1 2 3 4
3 2 1 5 2 1 6 5
(i) (ii)
2 3 6 1 3 6 4 1
6 1 4 2 4 3 2 6
11. In each case, is there a value for x such that the given array can be
embedded in a 6 × 6 Latin square? If so, what is that value? Give an
example of an embedding.
1 2 3 4 1 2 3 4
5 6 1 2 4 6 1 2
(i) (ii)
3 4 5 1 3 1 6 5
4 1 2 x 6 4 2 x
Exercises 13B
1. Write down the Latin square derived from the multiplication of integers
modulo 7.
3
can be completed to a Latin square.
1 2 3 4 5 6
6 1 4 3 2 5
4 5 1 6 3 2
8. Consider the problem in Exercise 11A.6. Suppose Drs. Johns and Wal-
ters wish to invite n2 colleagues from n universities, each of which sends
one person from each of n disciplines. They wish to seat these people
in a square grid so that no row or column contains two people from the
same discipline or from the same university.
(i) For what n is there a seating plan that accomplishes this?
(ii) For what n is there a plan in which no member of College A sits
next to a member of College B?
(iii) For what n is there a plan in which each member of discipline d1
is sitting next to a member of discipline d2 ?
9. Verify that the array in Figure 13.2 yields a golf design for 17 teams.
Latin Squares 263
Problems
1 3 5
1 3
4 5 2
3 4 1
4 5
1 3 5
1 3
1 .
4
5
Chapter 14
Balanced Incomplete Block Designs
B1 = {x1 , x2 , x3 }
B2 = {x4 , x5 , x6 }
B3 = {x1 , x2 , x5 }
B4 = {x3 , x4 , x6 }.
We could compare the yield for varieties x1 and x2 twice (using blocks B1 and
B3 ).
Such an arrangement of varieties into blocks is called an experimental de-
sign, because they were first studied as tools for conducting experiments, such
as the agricultural experiment we have outlined, or designs for short. In the
265
266 Introduction to Combinatorics
particular case when all the blocks are the same size (like our example) the
term block design is used.
In the 24-plot example that we mentioned first, each block is a complete
set of all the varieties. This is called a complete design. Designs like our
second example, whose blocks are proper subsets of the varieties, are called
incomplete.
Formally, we define a block design with parameters v, b, k to be a way of
choosing b subsets of size k (called blocks) from a set V of v objects called
varieties (or treatments). We say the design is based on V . A block design
is regular if every variety occurs in the same number of blocks. This is often
a desirable property when the data is analyzed, because we have the same
amount of information about each variety. If a block design is regular, it
is also called a 1-design; the number of blocks in which a treatment occurs
is called the replication number or frequency of the design, and is usually
denoted r.
The word incidence is used to describe the relationship between blocks and
varieties in a design. We say block B is incident with treatment t, or treatment
t is incident with block B, to mean that t is a member of B. When we study
designs, we shall primarily be involved with incidence and other structural
properties of a collection of subsets of the varieties. It makes no difference
whether the varieties are labels representing types of experimental material
(such as corn), or positive integers, or whatever. We are purely interested
in the combinatorics of the situation. For this reason, the objects we are
discussing are often called combinatorial designs.
Proof. We count, in two different ways, all the ordered pairs (x, y) such that
variety x belongs to block y. Since every variety belongs to r blocks, there
are r ordered pairs for each variety, so the number is vr. Similarly, each block
contributes k ordered pairs, so the summation yields bk. Therefore bk = vr.
If x and y are any two different varieties in a block design, we refer to the
number of blocks that contain both x and y as the covalency of x and y, and
write it as λxy . Many important properties of block designs are concerned
Balanced Incomplete Block Designs 267
with this covalency function. The one that has most frequently been studied
is the property of balance: a balanced incomplete block design, or BIBD, is
a regular incomplete design in which λxy is a constant, independent of the
choice of x and y. This constant covalency is called the index of the design.
Balanced incomplete block designs were defined (essentially as a puzzle) by
Woolhouse [140], in the annual Lady’s and Gentleman’s Diary, a “Collection
of mathematical puzzles and aenigmas” that he edited. The Reverend T. P.
Kirkman [57, 58, 59, 60] studied the case of block size 3; in particular he
introduced his famous “schoolgirl problem”[59]:
A schoolmistress has 15 girl pupils and she wishes to take them
on a daily walk. The girls are to walk in five rows of three girls
each. It is required that no two girls should walk in the same row
more than once per week. Can this be done?
The solution is a balanced incomplete block design with v = 15, k = 3, λ = 1
with additional properties. Yates [142] first studied balanced incomplete block
designs from a statistical viewpoint.
A balanced design with λ = 0, or a null design, is often called trivial,
and so is a complete design. We shall demand that a balanced incomplete
block design be not trivial; since completeness is already outlawed, the added
restriction is that λ > 0.
It is usual to write λ for the index of a balanced incomplete block design. We
often refer to a balanced incomplete block design by using the five parameters
(v, b, r, k, λ), and call it a (v, b, r, k, λ)-design or (v, b, r, k, λ)-BIBD.
As an example, here is a (7, 7, 4, 4, 2)-BIBD:
B1 = {x1 , x2 , x3 , x4 }
B2 = {x1 , x4 , x5 , x6 }
B3 = {x1 , x2 , x5 , x7 }
B4 = {x1 , x3 , x6 , x7 }
B5 = {x3 , x4 , x5 , x7 }
B6 = {x2 , x3 , x5 , x6 }
B7 = {x2 , x4 , x6 , x7 }.
Proof. Consider the blocks of the design that contain a given variety, x say.
There are r such blocks. Because of the balance property, every variety other
268 Introduction to Combinatorics
than x must occur in λ of them. So if we list all entries of the blocks, variety
x is listed r times and we list every other treatment λ times.
The list contains rk entries. So:
rk = r + λ(v − 1),
r(k − 1) = λ(v − 1).
Relations (14.1) and (14.2) allow us to find all parameters of a BIBD when
only three are given. For example, if we know v, k and λ, we can calculate r
from (14.2) and then deduce b using (14.1). As an example, if v = 13, k = 3
and λ = 1, we have r = λ(v−1)/(k−1) = 12/2 = 6 and b = vr/k = 13×6/3 =
26, and a (13, 26, 6, 3, 1)-design exists. But not all sets {v, k, λ} give a design.
First, all the parameters must be integers; for example, if v = 11, k = 3
and λ = 1, we would get r = 5 and b = 55/3; you cannot have a fractional
number of blocks, so this is impossible. And even when the parameters are
all integers, there might be no corresponding design; for example, there is
no (22, 22, 7, 7, 2)-design (see Section 14.3), even though both equations are
satisfied. In fact, whether there exists a design corresponding to a given set
of parameters is not known in general.
There is no requirement that all the blocks in a design should be different.
If two blocks have the same set of elements, we say there is a “repeated block.”
A design that has no repeated block is called simple.
If a design has b blocks B1 , B2 , . . . , Bb and v varieties t1 , t2 , . . . , tv , we define
a v × b matrix A with (i, j) entry aij as follows:
1 if ti ∈ Bj ;
aij =
0 otherwise.
This matrix A is called the incidence matrix of the design. The definition
means that each block corresponds to a column of the incidence matrix, and
each variety corresponds to a row.
Example 14.1: Exhibit the incidence matrix of the regular design with
varieties t1 , t2 , t3 , t4 and blocks B1 = {t1 , t2 }, B2 = {t3 , t4 }, B3 = {t1 , t4 },
B4 = {t2 , t3 }.
1 0 1 0
1 0 0 1
This design has incidence matrix A = 0 1 0 1 .
0 1 1 0
When we define designs, the order of the varieties does not matter. Sim-
ilarly, the order of the set of blocks is not important. So we do not usually
distinguish between two designs if the incidence matrix of one can be obtained
by reordering the rows and/or columns of the incidence matrix of the other.
Two such designs are called isomorphic.
Balanced Incomplete Block Designs 269
0 0 1 1
1 1 0 0 1 0 0 0 1 0 1 0 1 0 0 0
0 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0
= .
1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0
0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1
B = P AQ,
where
1 0 0 0 1 0 0 0
0 0 0 1 0 0 1 0
P =
0
,Q= .
1 0 0 0 1 0 0
0 0 1 0 0 0 0 1
The permutation matrix P represents the reordering of the varieties, and
could be obtained by performing the same reordering on the rows of the 4 × 4
identity matrix. Matrix Q represents the block reordering.
As usual, we write Jmn for an m × n matrix with every entry 1. (If m = n,
we simply write Jn ; and if the order is obvious from the context, we omit
subscripts altogether.) Also, In (or simply I) is an n × n identity matrix.
b
X b
X
aip aip = a2ip ;
p=1 p=1
aip ajp is 1 when varieties i and j both belong to block p, which happens λ
times for given i and j, and 0 otherwise. So the sum is λ. Therefore AAT has
diagonal entries r and off-diagonal entries λ; that is,
Equation (14.3) implies that every block has size k. From (14.4) the design
has constant replication number r (because of the diagonal entries of AAT )
and constant covalency λ (from the off-diagonal elements). So the design is a
(v, b, r, k, λ)-BIBD with incidence matrix A. The equalities (14.5) now follow
from (14.1) and (14.2).
follows from the fact that every variety belongs to r blocks, so each row of A
contains r 1’s.
LEMMA 14.4
The determinant of
r λ λ ... λ
λ r λ ... λ
M =
λ λ r ... λ
... ...
λ λ λ ... r
is (r − 1)v−1 [r + λ(v − 1)].
because A is v × b. Therefore v ≤ b.
λJAT = kJ (14.8)
and
λAT A = (k − λ)I + λJ. (14.9)
JA = kJ, (14.10)
AJ = kJ, (14.11)
and
AAT = (k − λ)I + λJ. (14.12)
COROLLARY 14.6.1
In a symmetric balanced incomplete block design, any two blocks intersect in
λ blocks.
A block design whose blocks have constant-size intersection is called linked .
So the corollary tells us that a symmetric balanced incomplete block design
is also a linked design.
In general, if a design D has incidence matrix A, the design with incidence
matrix AT is called the dual of D, and is often denoted D∗ . The dual of
any balanced incomplete block design is linked, but the only incomplete block
designs that are both symmetric and linked are SBIBDs.
The following important theorem is called the Bruck–Chowla–Ryser Theo-
rem.
Proof. Part (i) only: Suppose v is even, and suppose there exists a (v, k, λ)-
design with incidence matrix A. Since A is square it has a determinant,
denoted det(A), where det(AT ) = det(A), so
q
det(A) = det(AAT ).
det(AAT ) = k 2 (k − λ)v−1 ,
274 Introduction to Combinatorics
so
1
det(A) = ±k(k − λ) 2 (v−1) .
Now A is an integer matrix, so√det(A) is an integer. Since k and λ are integers,
and v is even, it follows that k − λ is an integer also.
The proof of part (ii) requires more mathematical background than we are
assuming. See, for example, Chapter 7 of [123].
For example, consider the case k = 7, λ = 2. From (14.7), v must equal 22;
but this is even, so no (22, 7, 2)-design exists.
Some applications require some harder results from number theory, but we
shall give one example where all you need to know is that 2 is not a square in
the arithmetic modulo 3.
Example 14.2: Show that no (141, 21, 3)-design exists.
Suppose a (141, 21, 3)-design exists. Then there are integers x, y and z, not
all zero, such that
x2 = 18y 2 + 3z 2 .
Without loss of generality we can assume that x, y, z have no mutual common
factor. Clearly, 3 must divide x2 , so 3 divides x: say x = 3e. Then
9e2 = 18y 2 + 3z 2
e2 ≡ 2y 2 (mod 3).
of index λ when B ranges through the remaining blocks, and the blocks B ∩B0
form a balanced design of index λ − 1. We shall refer to these as the residual
and derived designs of the original design with respect to the block B0 .
In general the replication number of a residual or derived design is not
constant, and the block sizes follow no particular pattern. If each variety in
the original design occurs r times, its residual and derived designs also have
constant replication numbers, r and r − 1 respectively.
The block pattern can be predicted if the original design is linked, that is
the size of B ∩ B0 is constant; the blocks of the derived design will be of that
constant size, and the blocks of the residual design will be |B ∩ B0 | smaller
than the blocks of the original. In particular, if we start with a symmetric
balanced incomplete block design, we obtain constant replication numbers
and block sizes.
provided λ 6= 1.
Figure 14.1 shows the designs. The first column shows the blocks of a
(11, 6, 3)-design B. The other columns show the blocks of the residual design R
and the derived design D with respect to the first block (block {1, 2, 3, 4, 5, 6}).
Designs R and D have parameters (5, 10, 6, 3, 3) and (6, 10, 5, 3, 2), respec-
tively.
Suppose a balanced incomplete block design D has parameters (v − k, v −
1, k, k − λ, λ) for some integers v, k and λ. One could ask whether there is a
(v, k, λ)-design for which D is the residual. The answer is “not necessarily,”
but in most cases there must be such a symmetric design. The exact situa-
tion is given by the following theorem, which is proven in various texts (for
example, [50]).
B R D
1 2 3 4 5 6
2 5 6 7 10 11 7 10 11 2 5 6
1 4 6 7 8 10 7 8 10 1 4 6
2 4 5 7 8 9 7 8 9 2 4 5
3 5 6 8 9 10 8 9 10 3 5 6
3 4 6 7 9 11 7 9 11 3 4 6
1 3 5 7 8 11 7 8 11 1 3 5
1 2 6 8 9 11 8 9 11 1 2 6
1 2 3 7 9 10 7 9 10 1 2 3
2 3 4 8 10 11 8 10 11 2 3 4
1 4 5 9 10 11 9 10 11 1 4 5
FIGURE 14.1: Residual and derived designs.
Notice that instead of {1, 2, 4} we could have used {0, 1, 3} or {2, 3, 5} or any
of the seven blocks. (These other blocks are called shifts of the original block.)
278 Introduction to Combinatorics
v k λ Difference set
15 7 3 1, 2, 3, 5, 6, 9, 11
21 5 1 1, 2, 7, 9, 19
73 9 1 1, 2, 4, 8, 16, 32, 37, 55, 64
37 9 2 1, 7, 9, 10, 12, 16, 26, 33, 34
FIGURE 14.2: Some difference sets.
COROLLARY 14.10.1
If there is a (v, k, λ)-difference set, then λ(v − 1) = k(k − 1).
Example 14.4: Construct a (7, 4, 2)-difference set D.
There will be exactly two pairs of elements whose difference is 1; without
loss of generality we might as well take one of them as 1 and 2 (if we took
values t and t+1, we would obtain a shift of a block containing 0 and 1). So the
set is {1, 2, x, y} for some x and y. Now we need another pair with difference
1; the possibilities are that D contains {0, 1} (D = {0, 1, 2, x} for some x), D
contains {2, 3} (D = {1, 2, 3, x}), or y = x + 1 (D = {1, 2, x, x + 1}). In the
first case x 6= 3 or 6, because these both give a third pair with difference 1.
So the possibilities are {0, 1, 2, 4} and {0, 1, 2, 5}. To test the first one, we see
that the differences of the elements are
{±(1 − 0), ±(2 − 0), ±(4 − 0), ±(2 − 1), ±(4 − 1), ±(4 − 2)}
= {±1, ±2, ±4, ±1, ±3, ±2},
{±(2 − 1), ±(4 − 1), ±(5 − 1), ±(4 − 2), ±(5 − 2), ±(5 − 4)}
= {±1, ±3, ±4, ±2, ±3, ±1},
and there is only one difference ±2, so this is not a difference set. The other
example does not work either. So there are 14 candidates for D—the two
examples that work and their shifts.
Figure 14.2 shows some further examples of difference sets.
The process of starting with one block, adding 1 to each member to form
a second block, then continuing, is called developing the block. We are only
dealing with cases where the elements are integers modulo v (called developing
mod v), but the same process can be carried out in other arithmetic structures,
such as groups. It is also possible to develop more than one block. For
example, consider the blocks {1, 2, 3, 5} and {1, 2, 5, 7} modulo 9. The first
Balanced Incomplete Block Designs 279
v b r k λ Initial blocks
41 82 10 5 1 {1, 10, 16, 18, 37}; {5, 8, 9, 21, 39}
13 26 12 6 5 {1, 2, 4, 7, 8, 12}; {1, 2, 3, 4, 8, 12}
16 80 15 3 2 {1, 2, 4}; {1, 2, 8}; {1, 3, 13}; {1, 4, 9}; {1, 5, 10}
22 44 14 7 4 {1, 7, 12, 16, 19, 21, 22}; {1, 6, 8, 9, 10, 14, 20}
FIGURE 14.3: Some supplementary difference sets.
Exercises 14A
1. You need to construct a block design with five blocks of size 2, based
on variety-set {1, 2, 3}, in which every possible pair of varieties occurs
at least once. Prove that there are exactly two non-isomorphic ways to
do this. Give examples.
6. Suppose S is a set with v elements, v > 2. Write 2(S) for the set of all
unordered pairs of elements of S. Show that if we take the members of S
as varieties and the members of 2(S) as blocks, the result is a balanced
incomplete block design. What are its parameters?
280 Introduction to Combinatorics
7. In each row of the following table, fill in the blanks so that the parame-
ters are possible parameters for a balanced incomplete block design, or
else show that this is impossible.
v b r k λ
35 3 1
21 28 3
11 5 5
14 7 4
12 6 3
49 7 1
8. Show that there do not exist symmetric balanced incomplete block de-
signs with the following parameters: (46, 10, 2), (52, 18, 6).
9. Suppose D is a balanced incomplete block design with parameters
(v, b, r, k, λ). The design tD is defined to have tb blocks: each block
B of D gives rise to precisely t blocks, each with the same set of vari-
eties as B. Prove that tD is a balanced incomplete block design. What
are its parameters? (The design tD is called the t-multiple of D.)
10. The balanced incomplete block design D has parameters (6, 10, 5, 3, 2)
and blocks
B0 = {0, 1, 2} B5 = {1, 2, 5}
B1 = {0, 1, 3} B6 = {1, 3, 4}
B2 = {0, 2, 4} B7 = {1, 4, 5}
B3 = {0, 3, 5} B8 = {2, 3, 4}
B4 = {0, 4, 5} B9 = {2, 3, 5}.
Construct the blocks of the dual of D, and verify that it is not balanced.
11. For the following parameter sets, what are the residual and derived
parameters?
(i) (23, 11, 5)
(ii) (15, 7, 3)
(iii) (45, 12, 3)
(iv) (13, 9, 6)
(v) (69, 17, 4)
12. Find an (11, 5, 2)-difference set.
13. Find two initial blocks whose development modulo 13 yields a (13, 26, 6,
3, 1)-design.
Balanced Incomplete Block Designs 281
Exercises 14B
1. A combinatorial design has six varieties, {1, 2, 3, 4, 5, 6}, and nine blocks
of size 2. Every variety occurs in three blocks, and the design is simple
(no two blocks are identical). Prove that there are exactly two non-
isomorphic ways to do this.
2. Prove that any two (4, 4, 3, 3, 2)-designs must be isomorphic.
3. In each row of the following table, fill in the blanks so that the parame-
ters are possible parameters for a balanced incomplete block design, or
else show that this is impossible.
v b r k λ
7 14 3
6 4 2
13 6 1
17 8 5
30 7
33 44 6
9. For the following parameter sets, what are the residual and derived
parameters?
(i) (16, 6, 2)
(ii) (22, 7, 2)
(iii) (15, 8, 4)
(iv) (31, 10, 3)
(v) (41, 16, 6)
11. Verify that the examples given in Figure 14.2 are, in fact, difference sets
with the stated parameters.
12. Suppose D is a (v, k, λ)-difference set. Write E for the set of all integers
modulo v that do not belong to D. Prove that E is a (v, v−k, v−2k+λ)-
difference set.
13. Verify that {0, 1, 2, 5} is a (7, 4, 2)-difference set, but {1, 2, 5, 6} is not.
Problems
Prove that the residual design of E with respect to S\B is the complement of
the derived design of D with respect to B. Select any block B of D. Prove
that the residual design of E with respect to S\B is the complement of the
derived design of D with respect to B.
Problem 7: D is the (15, 15, 7, 7, 3)-design with blocks
Given [x0 , y0 ] = [1, 1] = [F1 , F2 ] (the first two Fibonacci numbers, as outlined
in Chapter 6), it follows that [x1 , y1 ] = [1, 2] = [F2 , F3 ], so we see [xn , yn ] =
[Fn+1 , Fn+2 ].
This gives us a faster method of computing a given Fibonacci number than
using the recurrence. To find F100 , we would take the matrix A in the example
and square it, then square the square to get A4 , and continue to A64 . Then
calculate A64 × A32 × A2 × [1, 1]T = [x97 , x98 ] = [F99 , F100 ]. This would be
nine matrix multiplications, as opposed to 98 iterations of the recurrence.
285
286 Introduction to Combinatorics
entry in the product to see Fk Fm + Fk+1 Fm+1 = Fk+m+1 . In this way, the
matrix identity allows us to see relationships among the Fibonacci numbers
that would be more tedious to prove without matrix methods. Other Fi-
bonacci identities are given easy matrix proofs in [106], and in the problems.
Other two-term recurrences may be treated similarly. (In fact, the differ-
ence between a “method” and a “trick” in mathematics is often said to be that
a trick only works in one case, where a method works in many; the matrix
technique with this convention is a “method,” because it works for many recur-
rences.) Suppose we look at the recurrence an+1 = can +dan−1 , with specified
initial values a1 , a2 . We seek a matrix A for which An [a1 , a2 ]T = [an+1 , an+2 ].
It is not hard to see that the first row will be [0, 1] and the second row (where
the recurrence “lives,” so to speak) will be [d, c] (note the reversal of the
coefficients!).
Although we have seen two ways in Chapter 6 to find an explicit formula
for an in a two-term linear homogeneous recurrence, we will explore a third
way that uses diagonalization. Recall that some square matrices have the
property that there exists a matrix P where P −1 AP = D is a diagonal matrix
(all entries aij are 0 unless i = j). If A has this property, we say A is
diagonalizable, and D’s non-zero entries are the eigenvalues of A and the
columns of P are the corresponding eigenvectors.
Example 15.2: Solve the recurrence an+1 = an + 6an−1 with initial con-
ditions a0 = 2, a1 = 1.
0 1
We want eigenvalues and eigenvectors of the matrix A = . The
6 1
characteristic equation det(λI − A) is λ(λ − 1) − 6 = λ2 − λ − 6. The roots are
λ1 = 3 and λ2 = −2. (The characteristic equation of the matrix is the same as
the characteristic equation of the recurrence that we discussed in Chapter 6.)
The eigenvector corresponding to λ1 is the solution to A~v = 3~v . We write
~v = [v1 , v2 ]T . There are infinitely many eigenvectors, so we arbitrarily let
v1 = 1; then A~v = 3~v gives us v2 = 3v1 , or ~v = [1, 3]T .
Similarly, the eigenvector [1, −2] has eigenvalue −2. We conclude that
1 1 .6 −.2 −2 0
P = ; P −1 = ; D = P −1 AP = .
−2 3 .4 .2 0 3
To solve the recurrence, we use the fact that a diagonal matrix may be
easily raised to any power.
n a0 −1 n 2 n −1 2
[an , an+1 ] = A = (P DP ) = PD P
a1 1 1
Linear Algebra Methods in Combinatorics 287
0 1 0 0 0 0
1 0 1 0 0 0
0 1 0 1 0 0
Rev Stop 1st 2nd 3rd 4th A=
0 0 1 0 1 0
0 0 0 1 0 1
0 0 0 0 1 0
FIGURE 15.1: Gear shift graph.
Now consider the question: We have shifted gears five times since we began
with the car in the initial Stop state. How many ways can we be in 3rd gear
now? Of course, this problem is easily solved by simply going through all
possible sequences of changes that might end in 3rd gear. But it becomes
significantly more difficult if we specify 50 or 200 (or n) changes in state. We
could also observe that to get to 3rd gear in n steps we must get to 2nd gear or
4th gear in n − 1 steps, and develop a recurrence, although this method would
fail if our graph were more complex, with more edges. Instead we consider a
6 × 6 matrix, the adjacency matrix A of the graph, which was introduced in
288 Introduction to Combinatorics
Chapter 10. This matrix has a 1 in the (i, j) position if there is an edge from
vertex i to vertex j, and a 0 otherwise. There is a theorem concerning the
adjacency matrix that is useful to us.
0 1 1 0 0 0
Start a Stop 0 0
1 1 0 0
0 0 0 0 1 1
A= 0 0
0 0 1 0
b d
0 0
0 0 0 1
c 0 0 0 0 0 0
FIGURE 15.2: State graph and adjacency matrix.
Proof. Multiply the left-hand side by A − I; see Problem 15.3 for details.
This theorem is the matrix analogue of the well-known formula for the sum
of a finite geometric progression. There is a similar analog for the sum of
an infinite geometric series, and that will apply in the case of the foregoing
example.
COROLLARY
P∞ i 15.2.1
−1
i=0 A = (I − A) , where A0 = I, and limn→∞ An = 0.
Proof. The proof of this corollary is a simple generalization of the proof from
calculus of the sum of an ordinary geometric series, applied to Theorem 15.2.
It is worth noting that the hypothesis that An → 0 is equivalent to the
assertion that all the eigenvalues of A are less than 1 in absolute value (or
modulus, if the eigenvalues are complex). The proof is beyond the scope of
this text.
Now applying the corollary to the matrix of our example, we find (I − A)−1
has a (1, 6) entry of 5, so there are a total of five paths from Start to Stop.
1 2 3 4 5 6 1 2 3 4 5 6
1 0 1 0 0 0 0 1 0 1 1 0 0 0
2 1 0 1 1 0 0 2 1 0 1 1 1 0
3 0 1 0 0 1 0 3 1 1 0 1 1 1
4 0 1 0 0 1 0 4 0 1 1 0 1 0
5 0 0 1 1 0 1 5 0 1 1 1 0 1
6 0 0 0 0 1 0 6 0 0 1 0 1 0
FIGURE 15.3: A diagram and two adjacency matrices.
1 2 3 4 5 6 1 2 3 4 5 6
1 0 1 0 0 0 0 1 0 1 1 0 0 0
2 0 0 1 1 0 0 2 0 0 1 1 1 0
 = 3 0 0 0 0 1 0 B̂ = 3 0 0 0 1 1 1
4 0 0 0 0 1 0 4 0 0 0 0 1 0
5 0 0 0 0 0 1 5 0 0 0 0 0 1
6 0 0 0 0 0 0 6 0 0 0 0 0 0
Now, however, if we raise these matrices to the sixth power, we get a matrix
of all zeros, because clearly we can move at most five steps before we come to
a halt. We can raise either  or B̂ to any lower power than 6; so if we find,
for example, B̂ 3 , its (1, 6) entry is 3, indicating three ways to go from square
1 to square 6 in three steps by crossing sides or corners and never moving to
a lower-numbered square. If we compute (I − B̂)−1 , we find its (1, 6) entry is
Linear Algebra Methods in Combinatorics 291
8, indicating that there areP∞ a total of 8 ways to walk from square 1 to square
6. How do we know that i=0 B̂ i converges? Simply because any power of B̂
past the fifth power is a matrix of all zeros! Another way to obtain the same
result would be to place a 1 in the (6, 6) entry of B̂, and raise the resulting
matrix to any power greater than 4. This would work because, for instance,
a walk from square 1 to square 6 in three steps would give us a unique walk
from square 1 to square 6 in four steps in which the last step was from square
6 to itself. The result is this matrix.
1 2 3 4 5 6 1 2 3 4 5 6
1 0 1 1 0 0 0 1 0 0 0 0 0 8
2 0 0 1 1 1 0 2 0 0 0 0 0 5
B̃ = 3 0 0 0 1 1 1 B̃ 5 = 3 0 0 0 0 0 3
4 0 0 0 0 1 0 4 0 0 0 0 0 1
5 0 0 0 0 0 1 5 0 0 0 0 0 1
6 0 0 0 0 0 1 6 0 0 0 0 0 1
Notice that any power of B̃ greater than 4 gives us the same matrix. We
get a matrix whose only non-zero entries are in column 6, and the (1, 6) entry
is, as expected, 8. Similar remarks apply to the matrix Â.
d
0 1 1 1 1
a c
1 0 0 0 1
A=
1 0 0 0 1
b 1 0 0 0 1
1 1 0 1 1
e
FIGURE 15.4: Digraph and adjacency matrix for the string problem.
Notice that the (5, 3) entry is 0, but the (3, 5) entry is 1. This represents
the existence of an edge from c to e but not from e to c, because we forbid
292 Introduction to Combinatorics
strings containing ec. Now any legal string of length n corresponds to a walk
along n − 1 edges of the graph and because arbitrarily long walks are possible,
there is no power n such that An = 0. An attempt to apply Corollary 15.2.1
will not work because the matrix (I − A)−1 does not have integer entries.
To enumerate walks of length 2, we find A2 , which has entries from 1 to 4,
indicating the number of walks with the corresponding first and last vertices.
Since the (5, 4) entry is 2, there are two walks of length from d to e. We can
see these walks from the diagram; they are d-e-e and d-a-e. The sum of all
the matrix entries is 46, so there are 46 strings of three characters that satisfy
the given constraints.
00 10 1 1 0 0
0 0 1 1
A=
1
1 0 0
01 11 0 0 1 0
FIGURE 15.5: Digraph and adjacency matrix.
Linear Algebra Methods in Combinatorics 293
In this case, a string of length n corresponds to n−2 steps along the digraph,
because one step (say from 01 to 11) corresponds to the string 011. Thus the
coefficient of xn in our generating function will be the number of strings of
length n + 2. Now we find the matrix (I − xA)−1 and add the entries. This
is more easily done with a symbolic algebra program than by hand, and gives
us the result f (x) = (−2x2 − 3x − 4)/(x3 + x2 + x − 1). Long division gives us
4 + 7x + 13x2 + 24x3 + 44x4 + 81x5 + . . . . For n = 2 there are clearly four such
strings, so we check for n = 3 and find seven strings. For n = 4 there are 13
strings, as we may check by enumeration, and we should be content that we
have not made any mistakes since the coefficients agree. Checking the cases
of n = 5 and n = 6 is a pleasant exercise in inclusion-exclusion. We may also
deduce, using the methods of Chapter 6, that the sequence an we are looking
at satisfies the recurrence an = an−1 + an−2 + an−3 .
We conclude with a look at another application of the transfer-matrix
method.
Example 15.8: In how many different ways may we cover all the squares
of a 4 × n chessboard with nonoverlapping dominos?
To solve this problem we represent it as a problem enumerating walks on
an appropriate graph. Let each row of a 4 × n chessboard be represented by
a string of four bits, where a 1 represents a domino in the vertical position
extending into the next row, and a 0 represents a domino in a horizontal
position or extending from the row below. It follows that the topmost row
must be represented by 0000. Of the 16 possible bit strings, we find only six
may represent rows of a properly covered 4×n chessboard. Thus, for example,
the string 0000 may represent a row containing two horizontal dominos, or
one horizontal domino and two vertical dominos that rise from the lower row,
or four vertical dominos from below. A little thought reveals that no binary
string with an odd number of 1s can work since it can never “fit” with the
topmost 0000 row. Similarly, a row represented by 1010 must be followed by
a row of 0101, and the two alternate, never leading to any way to create a
0000 row. The other strings are 0011, 0110, 1001, 1100, and 1111. Now we
make a graph of these six strings and make a directed edge from the first to
the next if a row of the chessboard corresponding to the first can fit below
one corresponding to the second. The graph and the matrix that corresponds
to it are shown in Figure 15.6.
For any specific n, the (2, 2)-entry of An will give the number of proper
coverings of a 4 × n chessboard by dominos. Thus, a walk of n = 3 steps, say
0000-1100-0011-0000, corresponds to the domino tiling of the 4 × 3 board in
which two vertical dominos occupy the lower-left four squares and two other
vertical dominos occupy the upper-right four squares; and horizontal dominos
occupy the upper-left and lower-right corners.
This matrix is large enough that to find (I − xA)−1 we use a computer
algebra system. In Mathematica, for instance, we define A and compute
(I − xA)−1 as follows.
294 Introduction to Combinatorics
B = Inverse[IdentityMatrix[6] - x*A];
B[[2,2]]
The semicolons at the end of each line suppress display of the results; the last
line produces the (2, 2)-entry of B, namely,
1 − 2x2 + x4
.
1 − x − 6x2 − x3 + 6x4 + 2x5 − x6
We can expand this in a power series:
Series[%,{x,0,10}]
X
Per(A) = a1,σ(1) a2,σ(2) . . . an,σ(n). (15.2)
σ∈V
Then the permanent of A again gives the number of SDRs of the associated
family of subsets; the proof is exactly analogous to the proof of Theorem 15.3.
Equation 15.1 is unsatisfactory as a way to compute the permanent; we
mentioned above that the equivalent of the familiar Laplace expansion for
the determinant will work. Thus, the permanent of any 2 × 2 matrix was
given at the beginning of this section as ad + bc; we can use this to compute
the permanent of a larger matrix. So if Ai is the result P of deleting row 1
and column i from the matrix A, we may write Per(A) = ni=1 a1,i Per(Ai ).
However, caution is required when using this technique. In particular, the
traditional shortcut to computing the determinant with Laplace expansion
is to perform some elementary row operations to create a row or column
with many zero entries, and expand about that row or column. This will
work because the determinant is invariant under elementary row or column
operations; however, the permanent is not. Thus, this shortcut will yield an
incorrect value for the permanent. It is permissible to expand the permanent
about a different row of the matrix, as this merely corresponds to relabeling
the vertices of the graph, or reordering the sets Bi . Also, because Per(AT ) =
Per(A), we may expand about any column when A is square.
1 2 3 4 5
A 1 1 1 0 0
PerA = Per
B 1 0 1 0 1
C 0 1 1 1 1
0 1 0 1 1 1 0 1 1 0 0 1
= Per + Per + Per
1 1 1 1 0 1 1 1 0 1 1 1
This equation came from expanding about the first row, corresponding to
the set A. We continue the process; for instance,
0 1 0 1
Per = Per[1 1 1] + Per[1 1 1].
1 1 1 1
Now, to find the permanent of a 1 × 3 matrix, we simply add the entries. In
this case, each of these permanents is 3. We get 18 SDRs in all from these
sets.
Example 15.11: The 4-rung ladder L4 and B(L4 ) are shown below. How
many matchings does this graph have?
2 4 6 8
1 1 0 0 1
3 1 1 0 1
5 0 1 1 0
7 0 1 1 1
We expand about the first row, as it has only two 1s; we obtain
1 0 1 1 1 0
Per(A) = Per 1 1 0 + Per 0 1 1 .
1 1 1 0 1 1
The first permanent on the right-hand side may be expanded about the first
row; the second, however, will most efficiently be expanded about the first
column (which has only a single non-zero element). We get
1 0 1 1 1 1
Per(A) = Per + Per + Per = 5.
1 1 1 1 1 1
The graph has five perfect matchings, verifiable by listing them.
298 Introduction to Combinatorics
n−m+1
Per(A) = ΣΠAn−m − ΣΠAn−m+1 +
1
n−1
· · · + (−1)m−1 ΣΠAn−1
m−1
This formula is different from the usual formula for derangements given in
Chapter 5.
Although Bartel Leendert van der Waerden conjectured that this inequality
was true back in 1926, it was not until 1981 that it was first established by
Linear Algebra Methods in Combinatorics 299
Exercises 15A
1. Explain how to find, for some square matrix A, the matrix A82 using
only 8 matrix multiplications.
5. A marker starts in square 1 and may move from a square to any square
sharing a side with that square. For each of the four diagrams shown,
find the adjacency matrix A of the graph. Compute (I − A)−1 if it
exists, and find the number of walks of six or fewer steps from square 1
to square 6.
All All
All All All All
All All All
All All
All All All All
AllAll
All All
6. For the same diagrams as the previous exercise, a marker may move to
a square with which its current square shares a side or a corner. As
above, find the adjacency matrix A, the matrix (I − A)−1 if it exists,
and the number of walks from square 1 to square 6 in six or fewer steps.
7. For the same diagrams as Exercise 5, a marker may move only to a
higher-numbered square with which its current square shares a side or
a corner. Find the adjacency matrix A by replacing all non-zero entries
below the main diagonal of the matrices from Exercise 6, find the matrix
(I − A)−1 if it exists, and compute the number of walks from square 1
to square 6 in six or fewer steps.
8. For the same diagrams, allow the marker to move as in Exercise 7, but
also to move from square 6 to square 6. Find (I − A)−1 , 6i=1 Ai , and
P
the (1, 6) entry of A6 . What is the number of ways to move from square
1 to square 6 in six or fewer moves?
9. Suppose that the set A consists of the odd numbers between 1 and 6
inclusive; B consists of the even numbers in that range; and C consists
of the numbers divisible by 3 in that range. Construct a matrix A and
use this matrix to find the number of possible SDRs for this collection
of sets.
10. Find the number of perfect matchings for the bipartite graph shown.
11. Use van der Waerden’s inequality to determine the minimum number
of perfect matchings of a 4-regular bipartite graph on 16 vertices (8 in
each part).
Linear Algebra Methods in Combinatorics 301
Exercises 15B
1. Explain how to find, for some square matrix A, the matrix A61 , using
at most nine matrix multiplications.
2. Solve each recurrence using the methods of this chapter:
(i) an+1 = 2an + 3an−1 , a0 = 2, a1 = 2.
(ii) an+1 = 2an + 3an−1 , a0 = 1, a1 = 5.
(iii) bn+1 = 2bn + 15bn−1 , b0 = 1, b1 = 1.
(iv) bn+1 = 2bn + 15bn−1 , b0 = 1, b1 = 5.
3. Suppose a machine has six states, A, B, C, D, E, and Halt. From state
A we may go to B or C; from B, we may go to C, D, or Halt ; from C
we may only go to D; from D we may go to E or Halt ; and from E we
may only go to C.
(i) Find the state digraph that represents this machine.
(ii) Find the adjacency matrix M of the digraph of part (i).
(iii) Compute M 6 ; in how many ways can the machine go from state A
to Halt in exactly six steps?
4. Let M be the matrix from the preceding exercise, and suppose M̂ is
formed from M by changing the (6, 6) entry from 0 to 1 (that is, allowing
the machine to go from state Halt to Halt ). Explain why this matrix
would be useful in determining the number of ways that the machine
can go from state A to state Halt in at most six steps. How will this
compare to calculating the matrix (I6 − M 6 )(I6 − M )−1 ?
5. A marker starts in square 1 and may move from a square to any square
sharing a side with that square. For each of the four diagrams shown,
find the adjacency matrix A of the graph. Compute (I − A)−1 if it
exists, and find the number of walks of six or fewer steps from square 1
to square 6.
All
All
All All All All All
All All All All All
All All
All AllAll All
All All
All All
6. For the same diagrams as the previous exercise, a marker may move to
a square with which its current square shares a side or a corner. As
above, find the adjacency matrix A, the matrix (I − A)−1 if it exists,
and the number of walks from square 1 to square 6 in six or fewer steps.
302 Introduction to Combinatorics
7. For the same diagrams as the previous exercise, a marker may move
only to a higher-numbered square with which its current square shares a
side or a corner. Find the adjacency matrix A by replacing all non-zero
entries below the main diagonal of the matrices from Exercise 6, find
the matrix (I − A)−1 if it exists, and compute the number of walks from
square 1 to square 6 in six or fewer steps.
9. For the set {1, 2, 3, 4, 5, 6, 7, 8}, there are three subsets A = {3, 4, 5, 6},
B = {2, 4, 7}, and C = {1, 4, 7, 8}. How many SDRs are possible?
10. Find the number of perfect matchings for the bipartite graph shown.
11. Use van der Waerden’s inequality to determine the minimum number
of perfect matchings of a 3-regular bipartite graph on 20 vertices (10 in
each part).
Problems
S = {x : x2 + 8x + 15 = 0}
(“the set of all x such that x2 + 8x + 15 = 0”). The set of integers from 1 to
10 is
{x : x integral, 1 ≤ x ≤ 10}.
Sometimes a vertical line is used instead of a colon, so we might instead write
{1, 2, . . . , 1} = {x : x ∈ Z, 1 ≤ x ≤ 10}.
305
306 Introduction to Combinatorics
One way is to list the elements: {0, 1, 2}. The listing could also be expressed
as {x : x integral, 0 ≤ x ≤ 2} (or {x : x ∈ Z, 0 ≤ x ≤ 2}). Or we could
note that 1, 2 and 3 are the solutions of x3 + 3x2 + 2x = 0, and write {x :
x3 + 3x2 + 2x = 0}.
The number of elements in a set is called its order or size. We shall denote
the order of S by |S| (another common notation is #(S)). For finite sets,
the order will be a non-negative integer; for infinite sets we usually use the
infinity symbol ∞.
Suppose n is a positive integer. The residue classes modulo n are the n sets
[0], [1], . . . , [n − 1], where [i] is the set of all integers that leave remainder i on
division by n:
x ∈ S ⇒ x ∈ T.
These laws extend to three or more sets in the obvious way: for example,
R ∪ S ∪ T = R ∩ S ∩ T.
Another property is that both union and intersection are idempotent . That
is,
S∪S =S∩S =S
for any set S.
We often illustrate sets and operations on sets by diagrams. A set R is
represented by a circle, and the elements of R correspond to points inside the
circle. If we need to show a universal set (for example, if complements are
involved), it is shown as a rectangle enclosing all the other sets. These illus-
trations are called Venn diagrams, because they were popularized by George
Venn [118, 119].
Here are Venn diagrams representing R ∪ S, R ∩ S, R, R\S and R ∩ S ∩ T ;
the set represented is shown by the shaded area, and a universal set is also
shown.
R S R S
R ∪S R∩S
R R S
_
R R\S
R
S T
R∩S∩T
Two sets are equal if and only if they have the same Venn diagram. In
order to illustrate this, we again consider the distributive law
R ∩ (S ∪ T ) = (R ∩ S) ∪ (R ∩ T ). (2)
R S R S R S
T T T
R S T R (S T)
R S R S R S
T T T
R S R T (R S) (R T)
FIGURE A.1: R ∩ (S ∪ T ) = (R ∩ S) ∪ (R ∩ T ).
(R ∪ S) ∩ C ⊆ (R ∪ T ) ∩ (S ∪ T ).
R S R S
T T
(R » S) « T (R » T) « (S » T)
Sometimes we draw a Venn diagram in order to represent some properties
of sets. For example, if A and B are disjoint sets, the diagram can be drawn
with A and B shown as disjoint circles. If A ⊆ B, the circle for A is entirely
inside the circle for B.
All planets directly circle stars; our Moon does not directly circle
the relevant star (the Sun); therefore the Moon is not a planet.
Sets; Proof Techniques 311
To examine this, we take the universal set to
be the set of all heavenly bodies, A to be the
set of all those bodies that directly circle stars, A m•
and B to be the set of all planets; m represents B
the Moon. We know B ⊆ A, so the sets look
like the diagram. As m ∈ / A, it must be in the
outer region, so it is certainly not in B. So the
argument is valid.
Some arguments that look logical at first sight turn out not to be valid.
For example, consider:
All planets directly circle stars; Halley’s Comet directly circles the
relevant star (the Sun); therefore Halley’s Comet is a planet.
The symmetric difference of two sets consists of all elements in one or other
but not both. That is, the symmetric difference of R and S is
R+S = (R ∪ S)\(R ∩ S)
= (R ∪ S) ∩ (R ∩ S)
= (R ∪ S) ∩ (R ∪ S), (10)
A + B = (A\B) ∪ (B\A),
S × T = {(s, t) : s ∈ S, t ∈ T }.
P (1) true
P (1) true ⇒ P (2) true , by 12,
∴ P (2) true;
P (2) true
P (2) true ⇒ P (3) true , by 12,
∴ P (3) true;
Proof. To apply induction, we can rephrase the statement as: Let P (n) be
the statement “|P(A)| = 2n for any n-element set A”; then P (n) is true for
all positive integers n. Since the elements of A do not matter, we may as well
assume A = {a − 1, a2 , . . . , an }.
First we consider the case n = 1, so A = {a1 }. Then P(A) = {∅, A}, so
|P(A)| = 21 and in this case the theorem is true. Now suppose the result
has been proved for n = k − 1 and assume n = k; we might as well say
A = A′ ∪ {ak } where A′ = {a − 1, a2 , . . . , ak−1 }. By the induction hypothesis
|P(A′ )| = 2k−1 . Any subset of A is either a subset of A′ or a subset of A′
with the element sk adjoined to it, so to each subset of A′ there correspond
two subsets of A. Hence |P(A)| = 2k−1 · 2 and the theorem is proved.
and the formula is proved correct when n = k. So, by induction, we have the
required result.
The following example looks geometrical, but it also yields to induction.
Example AA.6: Suppose n straight lines are drawn in two-dimensional
space, in such a way that no three lines have a common point and no two lines
are parallel. Prove that the lines divide the plane into 12 (n2 + n + 2) regions.
We proceed by induction. If n = 1, the formula yields 21 (1 + 1 + 2) = 2, and
one line does indeed partition the plane into two regions. Now assume that
the formula works for n = k − 1. Consider k lines drawn in the plane. Delete
one line. By induction, the plane is divided into 12 ((k − 1)2 + (k − 1) + 2) =
1 2
2 (k − k + 2) regions.
Now reinsert the (deleted) kth line. It must cross every other line exactly
once, so it crosses (k − 1) lines, and lies in k regions. It divides each of these
regions into two parts, so the k regions are replaced by 2k new regions; the
total is
1 2 1 2
2 (k − k + 2) − k + 2k = 2 (k − k + 2 − 2k + 4k)
2
= (k + k + 2),
and
R = {(1, 1), (2, 4)}.
If ρ and σ are binary relations from S to T , we define the union ρ ∪ σ and
the intersection ρ ∩ σ from S to T in the obvious way: (s, t) ∈ ρ ∪ σ if and only
if (s, t) ∈ ρ or (s, t) ∈ σ or both, and (s, t) ∈ ρ ∩ σ if and only if (s, t) ∈ ρ and
(s, t) ∈ σ. The notation agrees exactly with the usual set-theoretic notation.
If ρ is a binary relation from R to S, and σ a binary relation from S to T ,
then the composition ρσ is a binary relation from R to T , where r(ρσ)t if and
only if there exists at least one element s ∈ S such that rρs and sσt.
If ρ is a binary relation from R to S, and ν a binary relation from P to T ,
then the composition ρν is not defined unless P = S. But when it is defined,
composition of binary relations is associative.
318 Introduction to Combinatorics
(ρν)−1 = ν −1 ρ−1 .
elements on which an equivalence relation has been defined, so that the ele-
ments of a multiset are the equivalence classes of the underlying set.
The word ‘congruence is also used as follows: the relation “congruence
modulo n” for a positive integer n is defined on the set Z of integers by
specifying that a is congruent to b modulo n, written “a ≡ b(mod n),” if and
only if n | (a − b). In other words, two integers are congruent modulo n if and
only if they belong to the same residue class modulo n. It is easy to show
that congruence modulo n is an equivalence relation: since n | (a − a), the
relation is reflexive; if n | (a − b) then n | (b − a), so the relation is symmetric;
if n | (a − b) and n | (b − c) then we have a − b = kn, and b − c = ln, for
some k, l ∈ Z, hence a − c = (k + l)n and n | (a − c), which shows that the
relation is transitive. So congruence modulo n is an equivalence relation on
the integers.
Appendix 1 Exercises A
1. Suppose A = {a, b, c, d, e}, B = {a, c, e, g, i}, C = {c, f, i, e, o}. Write
down the elements of
(i) A ∪ B. (ii) A ∩ C.
(iii) A\B. (iv) A ∪ (B\C).
S1 = {2, 5},
S2 = {1, 2, 4},
S3 = {1, 2, 4, 5, 10},
S4 = {x ∈ Z+ : x is a divisor of 20},
S5 = {x ∈ Z+ : x is a power of 2 and a divisor of 20}.
4. Consider the data: All mathematicians are loners; all surgeons are rich;
no loners are rich. Which of the following conclusions can be drawn?
(i) No mathematicians are rich.
(ii) All surgeons are loners.
(iii) No one can be both a mathematician and a surgeon.
320 Introduction to Combinatorics
5. Show that
R+S =R+S
for any sets R and S.
6. Show that the following three statements are equivalent: S ⊆ T, S ∪T =
T, S ∩ T = S.
7. Prove the given proposition by induction.
(i) The sum of the first n odd positive integers is n2 .
Xn
(ii) r2 = 16 n(n + 1)(2n + 1).
r=1
8. Prove that the sum of the cubes of any three consecutive integers is a
multiple of 9.
9. The numbers x1 , x2 , . . . are defined as follows. x1 = 1, x2 = 1, and if
n ≥ 2 then xn+1 = xn + 2xn−1 . Prove that xn is divisible by 3 if and
only if n is divisible by 3.
10. Suppose ρ and σ are relations defined on S = {1, 2, 3, 4, 5} by the sets
ρ = {(2, 2), (3, 2), (3, 4), (4, 1), (4, 3), (5, 5)};
σ = {(2, 3), (1, 2), (3, 1), (3, 2), (4, 4), (4, 5), (5, 4), (5, 5)}.
(i) Find the set form of the composition ρσ.
(ii) What is the set form of the relation σρ?
(iii) What are the set forms of the relations ρρ and σσ?
11. Suppose A is the set Z × Z. Prove that the relation ρ on A, defined by
is an equivalence relation.
Appendix 1 Exercises B
1. Suppose
(i) A ∩ B. (ii) A ∪ C.
(iii) A\(B ∩ C). (iv) (A ∪ B)\C.
2. Suppose
(i) A ∩ B. (ii) A ∪ C.
(iii) A\(B ∩ C). (iv) (A ∪ B)\C.
4. In each case, are the sets S and T disjoint? If not, what is their inter-
section?
(i) S is the set of perfect squares 1, 4, 9, . . . ; T is the set of cubes
1, 8, 27, . . . of positive integers.
(ii) S is the set of perfect squares 1, 4, 9, . . . ; T is the set Π of primes.
5. R, S and T are any sets, and U is the universal set.
(i) Prove: if R ⊆ S and R ⊆ T , then R ⊆ (S ∩ T ).
(ii) Prove: if R ⊆ S, then R ⊆ (S ∪ T ).
9. Consider the data: the city zoo keeps all species of brown bears; all large
bears are dangerous; the city zoo does not keep any dangerous bears.
Which of the following conclusions can be drawn?
(i) No large bears are brown.
(ii) All species of large bears are kept in the city zoo.
(iii) Some large bears are kept in the city zoo.
(iv) No large bears are kept in the city zoo.
(v) No dangerous bears are kept in the city zoo.
322 Introduction to Combinatorics
A ∩ (B + C) = (A ∩ B) + (A ∩ C);
(A + B) ∩ C = (A ∩ C) + (B ∩ C).
13. Prove that R\(S\T ) contains all members of R ∩ T , and hence prove
that
(R\S)\T = R\(S\T )
is not a general law (in other words, relative difference is not associa-
tive).
(i) First, prove this without using Venn diagrams.
(ii) Second, prove the result using Venn diagrams.
14. Prove that union is not distributive over relative difference: in other
words, prove that the following statement is not always true:
(R\S) ∪ T = (R ∪ T )\(S ∪ T ).
(i) First, prove this without using Venn diagrams. (Hint: Use the fact
(R\S) ∪ S = R ∪ S.)
(ii) Now prove the result using Venn diagrams.
Prove that
1 1
an = 1 − 2n .
2 2
21. Prove that the following divisibility results hold for all positive integers
n.
(i) 2 divides 3n − 1.
(ii) 6 divides n3 − n.
(iii) 5 divides 22n−1 + 32n−1 .
(iv) 24 divides n4 − 6n3 + 23n2 − 18n.
22. In each case a binary relation from S = {1, 2, 3, 4, 5, 6, 7, 8, 9} to itself
is defined. For each of these relations, what is the corresponding subset
of S × S? For each relation, what is the inverse relation?
(i) x ρ y means y = x2 .
(ii) x β y means xy = 6.
(iii) x δ y means 3x < 2y.
23. The relation ρ is defined on {1, 2, 3, 4, 5} by
ρ = {(1, 1), (2, 2), (2, 3), (3, 3), (3, 4), (4, 3), (5, 5)}.
B.1 Definitions
A matrix is a rectangular array whose elements—the entries of the matrix—
are members of an algebraic structure with the operations of addition and
multiplication, where multiplication is commutative. Most commonly the en-
tries will be chosen from the real numbers, but one could restrict them to
integers, or to the two numbers 0 and 1, or allow members of some integral
domain or a more general structure. (We refer to a real matrix, a zero-one ma-
trix , and so on.) The possible entries are called the scalars for the particular
class of matrices.
The horizontal layers in a matrix are called rows and the vertical ones are
columns. A matrix with m rows and n columns is called an m × n matrix; we
refer to m × n as the shape or size of the matrix, and the two numbers m and
n are its dimensions.
Matrices are usually denoted by single uppercase letters. As an example,
consider the matrix
1 0 1 −2
M = −1 1 −4 1 .
1 −3 0 2
We refer to the entry in the ith row and jth column of a matrix as the
(i, j)-element (or entry). The (2, 3) element of M is −4. When no confusion
is possible, we write aij to denote the (i, j)-element of a matrix A, using the
lowercase letter corresponding to the (uppercase) name of the matrix, with
the row and column numbers as subscripts. A common shorthand is to write
[aij ] for A. We use the ordinary equality sign between matrices; A = B means
that A and B are the same shape and aij = bij for every i and j.
325
326 Introduction to Combinatorics
In general if M and N are two matrices with the same shape, the sum of
two matrices M = [mij ] and N = [tij ] is the matrix S = [sij ] defined by
M + N = N M and (M + N ) + P = M + (N + P ).
Because of the associative law, we usually omit the brackets and just write
M + N + P.
We can take the sum of a matrix with itself, and we write 2M for M + M ,
3M for M + M + M , and so on. This can be extended to multipliers other
than positive integers: if a is any scalar, aM will mean the matrix derived
from M by multiplying every entry by a. That is,
This matrix aM is the scalar product (or simply product ) of a with M . It has
the same shape as M . The scalar product obeys the laws
for any matrices M and N of the same shape and any scalars a and b. Notice
that if 1s is the multiplicative identity element of the scalars (for example, for
real matrices, 1s represents 1), then 1s M = M .
Omn denotes a matrix of shape m × n with every entry zero. Usually we
do not bother to write the subscripts m and n, but simply assume that the
matrix is the correct shape for our computations. O is called a zero matrix ,
and works for matrix addition like the number zero under ordinary addition:
if M is any matrix, then
M +O =M
Matrices and Vectors 327
Example B.1: Suppose t = (1, 2, 4), u = (−1, 3, 0) and v = (1, −2, 1).
Calculate t · u, (t − u) · v and (u · t).
If the dimensions are such that the product AB exists, the matrices A and
B are called conformable.
Matrix multiplication satisfies the associative law: provided the relevant
products all exist,
A(BC) = (AB)C
and the product is usually written ABC. However, the commutative law is a
different story. If A is 2 × 3 and B is 3 × 4, then AB is a 2 × 4 matrix but
BA does not exist. It is also possible that AB and BA might both exist but
might be of different shapes; for example, if A and B have shapes 2 × 3 and
3 × 2, respectively, then AB is 2 × 2 and BA is 3 × 3. And even when AB and
BA both exist and are the same shape, they need not be equal. For example,
1 2 1 1 5 1
= ;
1 3 2 0 7 1
1 1 1 2 2 5
= .
2 0 1 3 2 4
OA = O and AO = O.
This is not just one rule, but an infinite set of rules. If we write in the
subscripts, then the full statement is
If A is any r × s matrix, then Om,r A = Om,s for any positive integer m, and
AOs,n = Or,n for any positive integer n.
There are also matrices that act like the number 1: multiplicative identity
elements. We define In to be the n × n matrix with its (1, 1), (2, 2), . . . , (n, n)
entries 1 and all other entries 0. For example,
1 0 0
I3 = 0 1 0 .
0 0 1
B.3 Inverses
If the matrices A and B satisfy AB = BA = I, we say that B is an inverse
of A.
Which matrices have inverses? In the real numbers, everything but 0 has
an inverse. In the integers, only 1 and −1 have (integer) inverses, but we can
obtain inverses of other non-zero integers by going to the rational numbers.
The situation is more complicated for matrices.
Suppose A is an r × c matrix. Then AB has r rows and BA has c columns.
If the two are to be equal, then AB is an r × c matrix; and if this is to equal
an identity matrix, it must be square. So r = c, and A is also a square matrix.
So only a square matrix can have an inverse.
Moreover, there are non-zero square matrices without inverses. One obvious
example is a matrix with one row or one column all zeroes. But there are less
trivial examples, even if we restrict our attention to the 2 × 2 case.
Example B.3: Show that the matrix
2 1
A=
1 1
has an inverse, by construction.
If
x y
B=
z t
is an inverse, then AB = I, so
2 1 x y 2x + z 2y + t 1 0
= = .
1 1 z t x+z 2y + t 0 1
Comparing the (1, 1) entries of the two matrices, so 2x + z = 1; from the (2, 1)
entries, x + z = 0. So x = 1 and z = −1. Similarly, y = −1, t = 2. So
1 −1
B= .
−1 2
On the other hand,
3 1
C=
3 1
Matrices and Vectors 331
has no inverse: if
x y
D=
z t
were an inverse, then
2 1 x y 3x + z 3y + t 1 0
= = .
2 1 z t 3x + z 3y + t 0 1
Comparing (1, 1) entries again, 3x+z = 1, but the (2, 1) entries give 3x+z = 0.
This is impossible.
A matrix that has an inverse will be called invertible or non-singular ; a
square matrix without an inverse is called singular .
We said “an inverse” above; however, if a matrix has an inverse, it is unique.
We say “the inverse” (if one exists) and write A−1 .
C = CI = C(AB) = (CA)B = IB = B
(AB)−1 = B −1 A−1 .
Proof. We need to show that both (B −1 A−1 )(AB) and (AB)(B −1 A−1 ) equal
the identity. But (B −1 A−1 )(AB) = B −1 (A−1 A)B = B −1 IB = B −1 B = I =
AA−1 = AIA−1 = A(BB −1 )A−1 = (AB)(B −1 A−1 ).
332 Introduction to Combinatorics
B.4 Determinants
This is called the expansion along the ith row ; it may be shown that the value
does not depend on the choice of i, and there is a similar formula for expansion
along columns. For further discussion of determinants, see standard texts on
matrix theory and linear algebra, such as [3]; among other things, a square
matrix is non-singular if and only if its determinant is non-zero.
Appendix B Exercises A
1. Carry out the following matrix computations.
1 1 −1
(i) 3
−2 0 8
2 −1 2 −1
(ii) +
−1 0 −1 2
2 −1 2 3
(iii) 3 4 −2 + 2 2 2
−2 1 −1 0
x − 2 3 2z y 2z 3
2. Find x, y and z so that = .
y x y 6z y + 2 6z
3. Carry out the following vector computations.
(i) 3(2, 4, 1) (ii) 4(3, 1, −1)
(iii) (1, 3) + (2, 4) (iv) 2(2, −1, 2, 3) − 3(1, 3, −2, −3)
4. A is a 2 × 3 matrix; B is 2 × 3; C is 1 × 4; D is 3 × 2; E is 3 × 4; F
is 4 × 3; G is 3 × 3. Say whether the indicated matrix exists. If it does
exist, what is its shape?
334 Introduction to Combinatorics
8. Find the determinant of the matrix, and use it to invert the matrix or
show that it is singular.
56 21
(i) (ii)
23 42
Appendix B Exercises B
1. Carry out the following matrix computations.
8 −4 1 1
(i) 2 1 3 − 5 1 −2
−2 1 −2 0
3 −1 2 1
(ii) 3 2 2 − 2 4 −2
−2 3 −1 0
4 −1 1 −1
(iii) 3 −3
2 2 −1 3
2 −1 −1 1 −1 2
(iv) 2 +3
2 3 1 1 1 −2
x −1 y + 2 −1
2. Suppose = .
−1 3 −1 x
What are the values of x and y?
4. Suppose
1 −1 0 −1 3
A= , B= , C= ,
−1 1 2 2 2
1 3 1 −2 3
D= , E= , F = .
−1 0 1 0 −1
5. A is a 2 × 5 matrix; B is 2 × 5; C is 1 × 3; D is 5 × 2; E is 3 × 5; F
is 5 × 3; G is 5 × 5. Say whether the indicated matrix exists. If it does
exist, what is its shape?
(i) 2A − B (ii) AD (iii) CF
(iv) CF T (v) DA (vi) AGF
(vii) A2 (viii) D2 (ix) G2
6. In this exercise,
1 −1 3 0 −1 6
A= , B= , C= ,
−2 3 −1 4 4 2
−1 1 −1 1 −1 2
D= 1 3 3 , E = 1 0 , F = −1 ,
−2 2 0 2 2 2
G= 2 1 −1 , H= 2 2 , K= −1 2 .
Carry out the matrix computations, or explain why they are impossible:
(i) BF (ii) AC (iii) CF
(iv) BG (v) D2 (vi) EK + KB
11. Suppose A is a square matrix with one row all zeroes. Prove that A
has no inverse. Prove the corresponding result when one column is all
zeroes.
12. Find a matrix A such that
3 2 1 3
A = .
2 1 2 −1
13. Find the determinant of the matrix, and use it to invert the matrix or
show that it is singular.
−2 2 3 6
(i) (ii)
−2 1 2 5
3 2 4 6
(iii) (iv)
−1 1 5 7
3 2 4 3
(v) (vi)
6 4 1 1
14. A and B are any two matrices such that AB exists. Prove that B T AT
exists, and that
B T AT = (AB)T .
338 Introduction to Combinatorics
15. For the following matrices, show that A−1 exists, but AB = CA, even
though B 6= C.
2 −1 4 0 2 0
A= , B= , C= .
1 1 4 2 2 4
16. Suppose Mx denotes the 2 × 2 matrix
1 x
,
0 1
This appendix contains brief biographical sketches of some of the people who
have contributed to the development of combinatorics. If you are interested
in further information, we have cited relevant articles, in Wikipedia and else-
where. Several good books on the history of mathematics have concentrated
on biographical sketches; in particular, we recommend [6] and [16]. And nowa-
days, if you want further information about any mathematician, simply type
their name into your favorite web browser.
339
340 Introduction to Combinatorics
Russia’s leadership (as Catherine the Great took power), and Euler felt that
he was no longer welcome in Berlin.
Another fairly famous anecdote of Euler comes from his time in St. Pe-
tersburg. The French philosopher Denis Diderot was visiting the court of
Catherine the Great, and allegedly making a stir with his outspoken atheism.
The story goes that Euler was asked to embarrass Diderot, and a joke was ar-
ranged. Diderot was told that the famous mathematician had a mathematical
proof of the existence of God. Euler, according to this story, gave his “proof”
with the statement that “Sir, (a + bn )/z = x, therefore God exists!” Suppos-
edly, Diderot was so ignorant of mathematics that he did not realize that the
statement was nonsense. Since Diderot was an accomplished mathematician
himself, this story is widely assumed to be completely untrue; however, Bur-
ton ([16]) suggests that the incident may have occurred, in which case Diderot
would have realized at once that it was merely a practical joke.
He lost all sight in his right eye in 1738 (likely due to an infection), and lost
all sight in the other eye in 1766 due to a cataract. Remarkably, his blindness
did not impair his mathematical productivity in any way, and indeed some
of his most productive years occurred after his blindness. In part this was
due to an ability to perform mental calculations, and in part it was due to
an amazing memory; he was able to recite Virgil’s Aeneid from memory, for
example. His complete works are being published; there are 76 volumes, with
a few more to appear, consisting of his personal letters.
Garns developed the idea while working at the Daggett architecture firm in
Indianapolis around 1960, but it was not published until 1979, in Dell Pencil
Puzzles and Word Games.
Garns was born in Connersville, Indiana, and by his teens had moved to
Indianapolis with his father, W. H. Garns, an architect. He attended the
University of Illinois, and received a Bachelor of Science in architectural engi-
neering in 1926. He worked for his father’s firm until the Second World War,
when he became a captain in the US Army Corps of Engineers. He joined the
Daggett architecture firm after the war.
1954. In addition to the minimal spanning tree algorithm from Chapter 11,
his name is attached to the Kruskal tree theorem and the Kruskal–Katona
theorem.
Emanuel Sperner []
Emanuel Sperner (December 9, 1905 - January 31, 1980) was a German
mathematician. He was born in Waltdorf, in what is today Poland. He
obtained his doctorate in 1928 from the University of Hamburg for a disser-
tation that contained one of the two results for which he is known today; this
is Sperner’s Lemma, a result concerning the colorings of a triangulation of a
simplex. While geometrical in nature, this result is used to prove powerful
results in topology as well. In 1928, he also published what is now called
Sperner’s Theorem, a major result in the combinatorial discipline of extremal
set theory. His later work served to make him a major figure in modern
geometry as well.
He later worked in Beijing for a time before returning to Germany, where
he took a position at the University of Königsberg until the second World
War. He then worked for the German Navy for a time before resuming his
academic career at Oberwolfach, where he is regarded as one of the founding
members of the Oberwolfach Mathematical Institute. Other appointments
followed at Bonn and then at Hamburg, where he retired in 1974. He took
a number of visiting positions thereafter to institutions in the United States,
South Africa, and Brazil, and spent his final years in Sulzburg-Laufen, where
he died in 1980.
In 1886, Tarry published a general method for finding the number of Euler
circuits in a graph or multigraph [112]. Then, in 1895, he published a sys-
tematic method so solve a maze [113], using what is essentially a depth-first
search algorithm. In 1900 and 1901 [114] he solved Euler’s 36 Officer Problem,
showing that there is no pair of orthogonal Latin squares of order 6.
Tarry then went on to work on magic squares, producing a substantial
number of results.
Chapter 1
1. The sets are shown in grey.
(i) R S (ii) R S
T T
2. Select three “active” players. They proceed as if they were the only
players, in a team of three. All other players pass.
3. Let’s write Sn for the required sum, S = 1 + 3 + . . . + (2n − 3) + (2n − 1).
(i) Partition the first 2n integers into the sets of odd and even integers:
1 + 2 + 3 + . . . + (2n − 1) + 2n
= [1 + 3 + . . . + (2n − 3) + (2n − 1)] + [2 + 4 + . . . + (2n − 2) + 2n] ;
so Sn = [1 + 2 + 3 + . . . + (2n − 1) + 2n]−[2 + 4 + . . . + (2n − 2) + 2n].
Now Gauss’s formula tells us that
1 + 2 + 3 + . . . + (2n − 1) + 2n = 2n(2n + 1)/2 = n(2n + 1),
and obviously
2 + 4 + . . . + (2n − 2) + 2n = 2 [1 + 2 + . . . + (n − 1) + n]
= 2 [n(n + 1)/2] = n(n + 1).
So Sn = n(2n + 1) − n(n + 1) = n2 .
(ii) Clearly S1 = 1 = 12 . Assume Sn = n2 for n = 1, 2, . . . , r.
Then Sr+1 = Sr + (2r + 1) = r2 + (2r + 1) = (r + 1)2 .
4. ABC, ADE, AFG, BDF, BEG, CDG, CEF.
Case n = 1 is easy. Assume ri=1 i(i + 1) = 31 r(r + 1)(r + 2). Then
P
5.
r+1
X
1
i(i + 1) = 3 r(r + 1)(r + 2) + (r + 1)(r + 2)
i=1
r 1
= 3 + 1 (r + 1)(r + 2) = 3 (r + 1)(r + 2)(r + 3).
347
348 Introduction to Combinatorics
Chapter 2
1. Since there are 52 letters possible for the last three, the answer is 26 ×
26 × 102 × 523 , or 9, 505, 100, 800.
Solutions to Set A Exercises 349
2. Solution: Eight choices for first digit, two for second digit and 10 for
last digit gives us 160 area codes possible. If we remove the “x11”
possibilities, there are eight that we disallow; 211, 311, 411, 511, 611,
711, 811, and 911. Subtracting leaves us 152 area codes.
3. Solution: There are 24 choices for the first window, 23 for the second,
and so on. The result is 24!/19! = 5, 100, 480.
4. This is equivalent to finding (i) the total number of 4-digit numbers, (ii)
the number of 4-digit numbers with no repeated digits. The answer to
(i) is 9000 (all the numbers from 1000 to 9999). For (ii), there are 9
choices (any of 1 to 9) for the first digit (x say), 9 for the second (0 is
now available but x is not), 8 for the third and 7 for the fourth, so the
answer is 9 × 9 × 8 × 7 = 4536.
5. Consider the strings of 6 digits, from 000000 to 999999. (000000 repre-
sents 1,000,000; otherwise abcdef represents abc, def with leading zeroes
deleted.) There are six places to put 3; for each choice there are five
places to put 5; for each of these there are four places to put 7; there are
seven choices for each other number. The total is 6 × 5 × 4 × 73 = 41160.
6. Since the sites are mutually exclusive (the student will join only one
site), the addition principle applies; we add the numbers for each site.
For a given site, befriending one acquaintance does not affect whether or
not the student befriends another, so that the multiplication principle
applies. Thus, the first site provides the student with 23 or 8 possibil-
ities; the second, 25 = 32; the third, 64; and the fourth, 16. We add
these to find 120 possibilities.
7. There are C(4, 2) = 6 ways to choose the two sites. If the numbers of
acquaintances were different, we would have to add up the possibilities
for each of the six choices. Because the numbers are the same, each
chosen site gives us 24 or 16 possible ways to befriend or not befriend
the acquaintances on that site. We therefore have 6·16·16 = 1536 possible
outcomes.
8. This must be broken into cases, unfortunately. There is one way to
choose the two sites with four acquaintances; each site admits 16 possi-
bilities, so we have 256 possibilities for this case. There are four ways to
choose one site with four acquaintances and one with five; there are 16
possibilities for the former and 32 for the latter, for 2048 possibilities.
Then there is one way to choose both of the five-acquaintance sites, and
each of those sites admits 32 possibilities, giving 1024 possible outcomes
in this case. Since the three cases are mutually exclusive, we add the
results to obtain 3328 possibilities altogether.
9. If she neglects the underage friend, she has three friends to choose from
and seven restaurants, for 21 possibilities. If she chooses the underage
350 Introduction to Combinatorics
friend, she has one friend to choose from and four restaurants. Since
she is taking only one friend, the two are mutually exclusive, so she
has 25 possibilities. If she can afford to take two friends, then she has
C(3, 2) = 3 ways if she leaves the underage friend behind, and seven
restaurants. If she takes the underage friend, she has C(3, 1) = 3 ways
to choose the second friend, and four restaurants. We get 21 + 12 = 33
possibilities.
Solution: There are 63 ways to select three tutors from a set of 6; this
10.
gives us 20 ways to assign three tutors to the 2:00 PM shift.
11. 6·5 = 30, 7·6 = 42, 8·7 = 56.
12. 1, 7, 21, 35, 35, 21, 7, 1.
13. 1·x10 + 5·x7 + 10·x4 + 10·x + 5·x−2 + 1·x−5 .
14. We can rewrite Corollary 2.3.3 as
Pn
1 + k=1 (−1)k nk = 0.
Pn
So k=1 (−1)k kr = −1. Divide each term by −1.
15. C(6, 3) ways to get to the west corner of block b2 times C(5, 2) ways to
go from the east end of b2 to the northeast corner gives us 200 ways.
Since there are C(12, 5) = 792 total possible paths, we subtract to get
592 paths that do not pass through block b2.
16. There are 16 letters, of which 3 are S, 2 are L, 5 are E, 2 are P, and there
are one each of I, N, G, and T. This gives us 16!/(3!·2!·5!·2!·1!·1!·1!·1!)
or 7, 264, 857, 600.
17. We can write 3 as a sum in 10 ways: 1+1+1, 1+2+0, 1+0+2, 0+1+2,
2 + 1 + 0, 2 + 0 + 1, 0 + 2 + 1, 3 + 0 + 0, 0 + 3 + 0, and 0 + 0 + 3. Computing
3!/(1!1!1!) = 6, 3!/(2!1!0!) = 3, and 3!/(3!0!0!) = 1, we obtain
6·3x·5y ·7z
+ 3 (3x)2 ·5y + (3x)2 ·7z + (5y)2 ·3x + (5y)2 ·7z + (7z)2 ·3x + (7z)2 ·5y
Chapter 3
1. 0.26.
3. 1/6.
4. (i) (2, 0), (2, 1), (2, 2), (1, 0), (1, 1), (1, 2), (0, 0), (0, 1), (0, 2).
(ii) A = (2, 0), (2, 1), (1, 0), B = (2, 0), (1, 1), (0, 2),
C = (2, 0), (2, 2), (1, 1), (0, 0), (0, 2).
(iii) The probabilities of the different results are P (2, 0) = P (2, 2) =
P (0, 0) = P (0, 2) = 1/16, P (2, 1) = P (1, 0) = P (1, 2) = P (0, 1) = 1/8
and P (1, 1) = 1/4. So P (A) = 5/16, P (B) = 3/8, P (C) = 1/2.
H TH
H H
5. (i) (i) T T TT (ii) {H, T H, T T } (iii) 1/4.
7. Call the dice die 1 and die 2. There are six possible rolls on each die, or
36 possibilities, and 6 are doubles. So the probability is 6/36 = 1/6.
8. 1/10.
10. (i) Yes (ii) No; add to 1.4, not 1 (iii) Yes (iv) No, contains a negative
(v) No, contains a “probability” greater than 1 (and adds to more than
1).
Chapter 4
1. 7. (This is a pretty trivial exercise, but notice: if we associate pigeon-
holes with the six possible rolls, then seven rolls must result in at least
one pigeonhole with two or more occupants.)
2. Write A1 = a1 , A − 2 = a1 + a2 , . . . , An = a1 + a2 + . . . + an . If n
divides ai , put s = 1, t = i; we are done. If n never divides ai for any i,
write Sk for the set of all ai congruent to k modulo n. There are n sums
and they belong to n − 1 sets (since S0 is empty). So one set contains
at least two elements.
3. By pigeonhole principle, k = 5; for if each car carried only four or fewer
people, there would be at most 84 patrons in the club. We cannot
conclude k = 6 since if all the cars carried at most five people, we might
have had as many as 105 patrons.
4. Let Si be the number of returns completed when i days have passed.
Clearly S1 ≥ 1 and S50 ≤ 80. Also, the numbers {S1 + 19, . . . S50 + 19}
are between 20 and 99. So the set of 100 integers {Si : 1 ≤ i ≤ 50} ∪
{Si + 19 : 1 ≤ i ≤ 50} is a set of 100 integers between 1 and 99, and so
at least two of them must be equal. It follows that there are h, k such
that Sh = Sk + 19, as required.
5. Let Si be the total number of journal entries turned in by the end of the
ith class day. Clearly S1 ≥ 1 and S60 ≤ 90. Each of the 120 numbers
S1 , . . . S60 , S1 + 29, . . . S60 + 29 lies between 1 and 90 + 29 = 119, so there
must be some h and k with Sh = Sk + 29, as required.
P
6. Suppose t∈T t = k. Then k ≡ ℓ(mod n) for some ℓ, 0 ≤ ℓ ≤ n − 1. If
ℓ 6= 0, choose x = ℓ; if ℓ = 0, choose x = n.
7. “Ends in 01” is equivalent to “equals 1 mod 100.” Write p to represent
p mod 100. There are only finitely many different integers mod 100
(100 of them, to be precise!), so there must be repetitions among the
powers of p. Say pi = pj is such a repetition, where i > j. Since p is not
divisible by 2 or 5, p has an inverse mod 100. Then pi−j = pi p−j ≡ 1
mod 100, and i − j is positive.
8. Given n, define Si = {y : ni ≤ y < i+1 n }. The sets S0 , S1 , . . . , Sn−1
partition the real numbers from 0 to 1 (including 0 but not 1), so the
remainder on dividing kx by n lies in one of them, for any k. Write
xk for this remainder. If one of x1 , x2 , . . . lies in S0 , we are finished.
If not, consider x1 , x2 , . . . , xn . There are n numbers, and each lies in
one of the sets S1 , S2 , . . . , Sn−1 . So two of them—say xa and xb —lie in
the same set, Si say. Say b > a. Then xb − xa is the difference of two
Solutions to Set A Exercises 353
positive numbers, each greater than or equal to ni and less than i+1n . So
|xb − xa | < i+1
n − i
n < 1
n ; but |xb−a | = |xb − xa |, and we are finished.
9. The two are equal (simply exchange the labels A1 and A2 in the defini-
tion, in Theorem 4.12).
10. Suppose the edges of a complete graph are colored in red and blue so
that there is no red triangle or blue K5 . Select a vertex x. If there
are five red edges at that vertex, no two of the other endpoints of those
edges can be joined by a red edge, or else we would have a red triangle.
But the edges joining those five other endpoints cannot all be blue, or
we would have a blue K5 . So there are at most four red edges at x.
Now suppose there were nine blue edges at x. Consider the K9 formed
by the other nine endpoints and the edges joining them. By Example
3.9, this must contain either a red triangle or a blue K4 . The former
is not allowed; the latter together with x would form a blue K5 in the
original graph.
So there are at most four red and eight blue edges touching x. Therefore
the complete graph has at most 13 vertices (4 + 8 + 1—don’t forget to
count x).
Chapter 5
1. 199 − 66 − 18 + 6 = 121.
354 Introduction to Combinatorics
Chapter 6
1. (i) (x3 + 4x2 + x)/(1 − x)4 . (ii) (4x2 + 3x − 1)/(1 − x)3. (iii) x/(1 − x)4 .
(iv) 1/(1 − 3x) − 3/(2 − 4x).
2. (i) We expand (1 + x + x2 + x3 )3 and the coefficient of xn is the result.
This is 1 + 3x + 6x2 + 10x3 + 12x4 + 12x5 + 10x6 + 6x7 + 3x8 + x9 .
(ii) Similarly, (x + x2 + x3 )3 = x3 + 3x4 + 6x5 + 7x6 + 6x7 + 3x8 + x9 .
(iii) For at least two banana-walnut muffins, we expand (x2 + x3 )(1 +
x + x2 + x3 )2 , to get: x2 + 3x3 + 5x4 + 7x5 + 7x6 + 5x7 + 3x8 + x9 .
Solutions to Set A Exercises 355
We get n≥0 (2n − n)xn = 1/(1 − 2x) + x/(1 − x)2 . This simplifies to
P
6.
fa (x) = (1 − x − x2 )/(1 − 4x + 5x2 − 2x3 ). This gives us the recurrence
an = 4an−1 − 5an−2 + 2an−3 .
7. (i) fa (x) = x2 ex /2. (ii) fb (x) = e3x − e2x /2. (iii) fc (x) = 2ex . (iv)
fd (x) = e2x + 2ex .
9. (i) fa (x) = e4x . (ii) fb (x) = (ex − 1)4 . (iii) fc (x) = (x + x2 /2! + x3/3!)4 .
Chapter 7
1. A proper way of lining up customers ensures that we never have more
people offering us a twenty dollar bill than we have had people who pay
with ten dollar bills. This corresponds exactly to a sequence of left and
right parentheses where the number of right parentheses never exceeds
the number of left parentheses that have occurred. This is just Cn .
2. There are six ways to place three chords at one corner; six ways to draw
chords in the shape of the (possibly reversed) letter N; and two ways to
put chords in the form of an equilateral triangle.
3. Each dot is touched by exactly one arc; write a “(” below a dot whose
arc connects it to a dot to its right, and “)” below a dot whose arc
connects it to a dot on its left. Then a set of arcs corresponds exactly
to a proper sequence of parentheses.
4. C5 = C0 C4 + C1 C3 + C22 + C3 C1 + C4 C0 = 14 + 5 + 4 + 5 + 14 = 42.
356 Introduction to Combinatorics
C9 = 18 2
5. 9 /10. This is 18!/[10(9!) ] = (18 × 17 × 16 × 15 × 14 × 13 ×
12 × 11)/(2 × 3 × 4 × 5 × 6 × 7 × 8 × 9). Careful cancellation makes this
problem not too difficult; (17 × 16 × 14 × 13 × 12 × 11)/(8 × 7 × 6 × 4) =
(17 × 13 × 2 × 11) = 4, 862.
−1
6.
1 0 0 0 1 0 0 0
= −1 1 0 0 .
1 1 0 0
1 3 1 0 2 −3 1 0
1 7 6 1 −6 11 −6 1
7 7 7
7. 2 = 63; 3 = 301; 4 = 350.
4
8. 2 = 7.
6 6
9. 3 = 90; 3 × 3! = 540.
6
3 6
4 6
5 6
6
10. 3 3 + 2 3 + 1 3 + 0 3 = 350; 350 × 3! = 2100.
5
11. 3 × 3! = 150.
5
12. 2 = 15.
8
6
13. 4 4 × 4! = 109, 200.
14. B3 = 5; there are five ways, namely 1×154 = 2×77 = 7×22 = 11×14 =
2 × 7 × 11.
15. B8 = 4140.
7 7 7
16. 4 = −735, 5 = 175, and 6 = −21.
6
17. = 274; if one table is distinguished, we have 2 × 274 = 548.
2
Chapter 8
1. e ρ ρ2 ρ3 ρ4
e e ρ ρ2 ρ3 ρ4
ρ ρ ρ2 ρ3 ρ4 e
ρ2 ρ2 ρ3 ρ4 e ρ
ρ3 ρ3 ρ4 e ρ ρ2
ρ4 ρ4 e ρ ρ2 ρ3
Solutions to Set A Exercises 357
1 2 3 4 5
2. (i)
5 3 4 2 1
1 2 3 4 5
(ii)
2 4 3 5 1
3. (i) (13)(254); (ii) (12534).
4. For simplicity, we number the corners 1, 2, 3, 4 starting at the upper
left and moving clockwise. We may form a reflection across the horizon-
tal axis, corresponding to the permutation (14)(23); a reflection across
the vertical axis, corresponding to (12)(34), and a rotation by 180◦ ,
corresponding to (13)(24). Together with the identity e, this forms a
group.
Denote C2 = {e, α} and C3 = e, ρ, ρ2 . The group elements are
5.
(e, e), (e, ρ), (e, ρ2 ), (α, e), (α, ρ), (α, ρ2 )
Chapter 9
1. See the diagram on the left in the figure below.
All All
All All
All All
All
Chapter 10
1. Consider a graph with v vertices. All degrees are less than v. If all are
different, the degree sequence is (v − 1, v − 2, . . . , 1, 0). The vertex of
degree v − 1 is adjacent to every other vertex, but it cannot be adjacent
to the vertex of degree 0—a contradiction.
The multigraph example is
4. a, 1 b, 2 c, 3 d, 1 e, 2 f, 3.
6. Go along the path x, a, . . . until the first time you meet a vertex (other
than x) that appears in both paths. Say that vertex is c. Then follow
the second path back from c to y. The result is a closed walk containing
x. The walk will be a cycle unless it contains some repetition, and this
will only happen if a = b. In the latter case, the walk generated is not
a cycle, it goes xax, a repeated edge.
9. (i) Color G with two colors and apply a new third color to all new
vertices. (ii) No: for example, suppose G is a tree.
process. Each time we select a new vertex we use one edge, so if the
vertex has even degree there must be another edge that has not been
used, and we can go on. But the process must end, because there are
only finitely many edges. So we must eventually reach an odd vertex.
Chapter 11
1. (i) No; 1 (ii) Yes (iii) No; 3 (iv) Yes (v) No; 3 (vi) 3.
Solutions to (ii) and (iv) are found by the algorithm. Here are sample
solutions for the eulerizations.
(i) (iii) (v) (vi)
I II
6.
13. Say there are v vertices. There are v − 1 edges, so the degrees add to
2v − 2. Each degree is at least 1. Assume one vertex has degree n. Say
there are x of degree 1 and y of degree 2 or greater. Then x + y = v − 1;
the sum of degrees is at least n + x + 2y = n + x + 2(v − 1 − x) =
2v − 2 + n − x. So n − x ≤ 0, x ≥ n.
362 Introduction to Combinatorics
14. (i) For the multiple path, one has n choices of edge for each edge of the
underlying path, giving nv−1 paths in all.
(ii) For the multiple cycle, each spanning tree is a path; there are v
choices for the pair of adjacent vertices that will not be adjacent in the
spanning tree, and for each choice there are again nv−1 paths.
15. The following solutions were found using Prim’s algorithm. Even so,
they are not unique: For example, in (i), edge ad could have been chosen
instead of de.
(i) a b c (ii) a b 9 c
4
6 3 7 3 8 6 7
6
d 6 e f 6 d e
5 4
9 8 5 3
3
g h i f g h
5
(iii) a b c (iv) a b
6 5 3 5 4 5 8
3 6
c d
e f
d e
3
9 3 8 4 36 6 5 8 4
5
f 4 g g h i j
7
4 6 3 4 2
h j k l
4 i 4
Chapter 12
1. (i) 2. (ii) 8. (iii) 3. (iv) 5.
8. (i) 1001. (ii) 0010. (iii) 1001. (iv) 1101. (v) 1011. (vi) 1100.
1 0 0 1 1 0
9. 0 1 0 1 0 1 ; 1; 0.
0 0 1 0 1 1
(For example, you cannot decide whether 100000 was meant to be
000000 (decodes as 000) or 100100 (decodes as 100).)
Chapter 13
1.
0 1 2 3 4 5
1 2 3 4 5 0
2 3 4 5 0 1
.
3 4 5 0 1 2
4 5 0 1 2 3
5 0 1 2 3 4
2. Assume the symbols are 1, 2, 3, 4, 5. Then the (2, 1) and (2, 4) entries
are equal (there are many other problems).
3. (i) Suppose a Latin square L has first row (a1 , a2 , . . . , an ). Carry out
the permutation 1 7→ a1 , 2 7→ a2 , . . . , n 7→ an on the columns of L.
Permute the rows in the corresponding fashion.
(ii) Each reduced square gives rise to n! different squares by column
permutation. Once a column permutation is chosen, there are (n − 1)!
different row permutations available (leaving row 1 as the first row).
The n!(n − 1)! resulting squares are all different (any two will differ
somewhere in the first row or column).
(iii) r3 = 1, r4 = 4.
(iv) The reduced squares are:
1 2 3 4 1 2 3 4
2 1 4 3 2 1 4 3
3 4 1 2 3 4 2 1
4 3 2 1 4 3 1 2
1 2 3 4 1 2 3 4
2 3 4 1 2 4 1 3
.
3 4 1 2 3 1 4 2
4 1 2 3 4 3 2 1
Now the elements in each row of (as,t , B) are precisely the ordered pairs
(as,t , bj ), 1 ≤ j ≤ r, once each. As t ranges from 1 to n, as,t covers
each of a1 , a2 , . . . , an precisely once, so the (as,t , bj ) go through all the
(ai , bj ) once each, and each row of A × B contains each pair precisely
Solutions to Set A Exercises 365
once. This is the row property of a Latin square. The column property
is similar. If A and B are transversal squares, the transversal property
for A × B follows from the same argument.
5. (i) Where will the entry (1,1) occur in (A, AT )? If it is in position ij,
it also appears in position ji. To avoid two occurrences, we need i = j,
a diagonal position. So 1 appears on the diagonal somewhere. The
same argument applies to every symbol. So each of 1, 2, . . . , n is on the
diagonal. There is just enough room for each symbol to appear exactly
once.
(ii) Say A is a self-orthogonal Latin square of side 3 whose diagonal is
(1, 2, 3). The only possible (1, 2) entry is 3, and it is also the only possible
(2, 1) entry. Therefore (3, 3) appears too many times in (A, AT ).
(iii)
1 3 2 5 4
1 3 4 2
4 2 5 1 3
4 2 1 3
5 4 3 2 1 .
2 4 3 1
3 5 1 4 2
3 1 2 4
2 1 4 3 5
A C B D E 1 3 5 2 4
E A C B D 5 2 4 1 3
D E A C B 4 1 3 5 2.
B D E A C 3 5 2 4 1
C B D E A 2 4 1 3 5
1 2 3 4 5
5 1 2 3 4
4 5 1 2 3.
2 3 4 5 1
3 4 5 1 2
(Note: We did this solution in some detail because the same thinking
will apply to harder problems.)
10. (i) One example:
1 5 3 4 2 6
3 2 1 5 6 4
2 3 6 1 4 5
.
6 1 4 2 5 3
4 6 5 3 1 2
5 4 2 6 3 1
(ii) Impossible because 5 only appears once.
11. (i) x = 6 because there is only one 6 in the array. One solution is
1 2 3 4 6 5
5 6 1 2 3 4
3 4 5 1 2 6
.
4 1 2 6 5 3
6 3 4 5 1 2
2 5 6 3 4 1
Solutions to Set A Exercises 367
(ii) Impossible. There is only one 5 in the array, but x cannot equal 5
or there would be two 5s in column 4.
12. One example is
5 2 3 6 4 1
3 5 2 4 1 6
1 4 6 5 2 3
.
2 3 5 1 6 4
6 1 4 2 3 5
4 6 1 3 5 2
13. (i) Assume the diagonal is (1, 2, 3, 4, 5). The (1, 2) entry could be 3, 4 or
5; the case of 5 will be isomorphic to the case of 4 (apply permutation
(45) to rows, columns and symbols).
In the former case, the (1, 3) entry cannot be 2 (you would have a 3 × 3
subsquare; see Exercise 12A.7) so it might as well be 4 (the permutation
(45) could be used if the entry were 5). Then you get
1 3 4 5 2
3 2 1
4 1 3
5 4
2 5
and there is no possible (2, 4) entry.
In the latter case, the (1, 3) entry can be 2 or 5 (the permutation (45)
could be used if the entry were 5). If it is 2 there is no completion (the
first row must be (1, 4, 2, 5, 3) and the second row cannot be completed;
if it is 5, the unique solution is
1 4 5 3 2
4 2 1 5 3
5 1 3 2 4.
3 5 2 4 1
2 3 4 1 5
(ii) We would need one of the squares to have 3 in the (1, 2) position.
14. (i) Say there are t copies of 1 above the diagonal. Then there will also
be t copies of 1 below the diagonal, so there are n − 2t copies of 1 on the
diagonal. This number must be non-negative; since n is odd, it cannot
be zero. So it is positive. Similarly for all other entries; so there is at
least one of each symbol on the diagonal. Since there are only n diagonal
positions, each integer from 1 to n must appear there once.
(ii) Try a 2 × 2 square.
368 Introduction to Combinatorics
Chapter 14
1. Three blocks are 12, 23 and 13. The other two must be either two
copies of the same block (e.g., {12, 23, 13, 12, 12}) or different blocks
(e.g., {12, 23, 13, 12, 13}). Any example can be derived from one of these
two by permuting the names of varieties.
2. Write S for the set comprising the first v positive integers, and write
Ss for the set formed by deleting i from S. Then blocks S1 , S2 , . . . , Sv
form the required design.
7.
v b r k λ
15 35 7 3 1
21 28 3 r(k − 1) = 8; λ(v − 1) = 20λ > 8
11 11 5 5 2
14 7 4 v>b
12 6 3 11λ = 12; impossible
49 56 8 7 1
C0 = {0, 1, 2, 3, 4} C3 = {1, 3, 6, 8, 9}
C1 = {0, 1, 5, 6, 7} C4 = {2, 4, 6, 7, 8}
C2 = {0, 2, 5, 8, 9} C5 = {3, 4, 5, 7, 9}.
Since {0, 1} lies in two blocks and {0, 2} lies in one block, the design is
not balanced.
11. (i) (12, 22, 11, 6, 5), (11, 22, 10, 5, 4);
(ii) (8, 14, 7, 4, 3), (7, 14, 6, 3, 2);
(iii) (33, 44, 12, 9, 3), (12, 44, 11, 3, 2);
(iv) (4, 12, 9, 3, 6), (9, 12, 8, 6, 5);
(v) (52, 68, 17, 13, 4), (17, 68, 16, 4, 3).
12. One solution: {1, 3, 4, 5, 9}.
13. One solution: {1, 2, 5}, {1, 6, 8}.
Chapter 15
1. Square A; square the result; square again, and repeat until you get A64
(six multiplications). Then A64 × A16 × A2 gives A82 in eight multipli-
cations.
0 1
2. (i) Let A = . Its eigenvalues are 3 and −1. We find the cor-
3 2
1 1
responding eigenvectors and make them the columns of P = .
3 −1
3 0 2
The matrix D becomes . We find P −1 and P Dn P −1 to
0 −1 2
get an = 3n + (−1)n .
(ii) We use
the
same A, D, and P as for the previous exercise. Now
n −1 1
PD P gives us an = 3(3n ) − (−1)n .
7
0 1 1 1 4 0
(iii) Let A = . We get P = , D = , and
8 2 4 −2 0 −2
1 1
P −1 = 23 −1 6 . This gives us bn = 4n − 2(−2)n .
3 6
(iv) We use the same A, D, and P as for the previous part. We get
bn = 4n + (−2)n .
370 Introduction to Combinatorics
3.
A D
Halt
C B
A B C D Ha A B C D Ha
A 0 0 1 1 0 A 2 1 1 2 2
B 0 0 0 1 1 B 1 1 0 1 1
C 0 1 0 1 0 C 1 1 1 2 1
D 1 0 0 0 1 D 1 0 1 2 2
Ha 0 0 0 0 0 Ha 0 0 0 0 0
4.
A C
D B
Halt
A B C D Ha A B C D Ha
A 0 0 1 1 0 A 2 1 1 2 5
B 0 0 0 1 1 B 1 1 0 1 3
C 0 1 0 1 0 C 1 1 1 2 4
D 1 0 0 0 1 D 1 0 1 2 4
Ha 0 0 0 0 1 Ha 0 0 0 0 1
The matrix M̂ 4 has a (1, 5) entry equal to the number of ways in which
the machine can go from A to Halt in four or fewer steps. ThePproduct
∞
(I5 − M 5 )(I5 − M )−1 will not yield the correct answer because i=0 M i
does not converge. This is because we may make paths of arbitrary
length by shifting from A to D and back before ending at Halt.
8. In each case, the matrix A is just like the matrix for the last exercise,
except with a 1 for the (6, 6) entry. The matrix (I − A)−1 does not exist
in each case, because the geometric series will not converge.
a) 6i=1 Ai has a (1, 6) entry of 30, which is far too large. But A6 has
P
a (1, 6) entry of 9, which is the correct number of ways to move from
square 1 to square 6.
b) 6i=1 Ai has a (1, 6) entry of 12, which is far too large. But A6 has
P
a (1, 6) entry of 4, which is the correct number of ways to move from
square 1 to square 6.
c) 6i=1 Ai has a (1, 6) entry of 12, which is far too large. But A6 has
P
a (1, 6) entry of 4, which is the correct number of ways to move from
square 1 to square 6.
P6
d) i=1 Ai has a (1, 6) entry of 26, which is far too large. But A6 has
a (1, 6) entry of 8, which is the correct number of ways to move from
square 1 to square 6.
9. 1 0 1 0 1 0
A = 0 1 0 1 0 1 .
0 0 1 0 0 1
It is simplest to expand about the last row; in any event, we get four
1 × 4 matrices each containing three 1s, to give a permanent of 12.
10. 1 1 0 0 0
1 0 1 0 0
1 1 1 1 0 = 5.
Per
0 0 1 0 1
0 0 1 1 1
Appendix A
1. (i) {a, b, c, d, e, g, i}, (ii) {c, e}, (iii) {g, i}, (iv) {a, b, c, d, e, g}.
2. S1 ⊆ S3 , S4 ; S2 ⊆ S3 , S4 , S5 ; S5 ⊆ S2 , S3 , S4 ; S2 = S5 .
3. S ∪ T = U ⇒ S ⊆ T ; S ∩ T = ∅ ⇒ T ⊆ S.
k
X
r2 = 61 k(k + 1)(2k + 1).
r=1
k+1
X
r2 = 61 (k + 1)(k + 2)(2k + 3).
r=1
= 16 2k 3 + 3k 2 + k + (k + 1)2
= 16 2k 3 + 3k 2 + k + k 2 + 2k + 1
= 16 2k 3 + 3k 2 + k + 6k 2 + 12k + 6
= 61 2k 3 + 9k 2 + 13k + 6 .
Solutions to Set A Exercises 375
8.
(n − 1)3 + n3 + (n + 1)3
= (n3 − 3n2 + 3n − 1) + n3 + (n3 + 3n2 + 3n + 1)
.
= 3n3 + 6n
2
= 3n(n + 2).
10. (i) ρσ = {(2, 3), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (5, 4), (5, 5)}.
(ii) σρ = {(1, 2), (2, 2), (2, 4), (3, 2), (4, 1), (4, 3), (4, 5), (5, 1), (5, 3), (5, 5)}.
(iii) ρρ = {(2, 1), (3, 1), (3, 2), (3, 3), (4, 2), (4, 4), (5, 5)},
σσ = {(1, 3), (2, 1), (2, 2), (3, 2), (3, 3), (4, 4), (4, 5), (5, 4), (5, 5)}.
x + y = y + x for all x, y ∈ Z,
but that is just the commutative law for integers. Symmetry means
that, for all x, y, z, t,
x + t = y + z ⇒ z + x = t + y,
which follows from the commutative law for integers and the symmetric
law for equality. For transitivity, assume
x + t = y + zz + b = t + a.
(x + t) + (z + b) = (y + z) + (t + a).
x + b = y + a,
Appendix B
10 3
3 3 −3 4 −2
1. (i) . (ii) . (iii) 16 −2 .
−6 0 24 −2 2
−8 3
2. x = 11; y = 9; z = 23 .
3. (i) (6, 12, 3). (ii) 4(12, 4, −4). (iii) (3, 7). (iv) 2(1, −11, 10, 15).
4. (i) no; (ii) 1 × 3; (iii) no; (iv) 4 × 3; (v) no; (vi) no; (vii) no; (viii) 3 × 3;
(ix) 3 × 3.
1 3 0
6 −4 17 −14
5. (i) . (ii) . (iii) 1 3 0 .
3 1 9 −6
−1 −3 0
3 1 8
(iv) 1 0 . (v) 0 .
−1 −3 −1
5 −3
6. A= .
−10 7
2 −1 3 −2
7. (i) , .
−1 1 −2 1
1 −4 1 1 14 −5
(ii) 0 9 −5 , 0 −27 19 .
0 0 4 0 0 −8
1 −2
8. (i) 3; . (ii) 0; no inverse.
− 32 53
6 4 4
3 9
9. (i) AB = AC = . (ii) AB = AC = 4 3 4 .
3 9
8 5 4
Hints for Problems
Chapter 1
2. What if there is an element a such that aρb is never true for any b?
5. Think of chords.
7. Construct a graph whose vertices are the attendees (other than the
hostess); there is an edge if two people shook hands. The degrees must
be 0, 1, 2, 3, 4, 5, 6, 7, 8. Consider the person that shook hands eight
times; the only person he/she missed must be his/her spouse. What
does this tell you about the other vertices’ degrees?
8. Since E only belongs to O4 , clearly if E resigns no SDR is possible as
there are only four willing students and five organizations. However, if
D were to resign from O5 , then O1 , O2 , O3 would each consist of only
A and C among the willing students. Then, if student E were to join
either O1 or O3 , no one resignation could prevent an SDR.
Checking this is tedious but straightforward; clearly we only have to
check the possibility of a resignation of a student from the organization
that he or she represents in the SDR we found for part (i).
Chapter 2
2. 1001 = 11 × 91; 100001 = 11 × 9091. Generalize this.
4. A combinatorial proof could involve selecting a committee of k individ-
uals from a larger group of m men and n women; the right-hand side of
the equation sorts the possible committees according to gender makeup.
5. You may select a committee of k people, with a chair (or facilitator). You
might choose the chair first, and then choose the other k − 1 committee
members, or you might choose the committee as a whole first and then
select the chair from the chosen committee members.
377
378 Introduction to Combinatorics
Chapter 3
5. Let the three dice be distinct. Then consider the number of ways to get
a 9 if the low roll is a one; for instance, there are six rolls with values
{1, 3, 6}. Repeat for other values of the low roll.
9. The sum of a subset must lie between 6 and 30. There are 210 subsets,
and 25 sums. So the average number of subsets with a given sum is at
least 8. Try to improve this.
Chapter 4
2. We are virtually using the pigeonhole principle in a reverse form; that
is, if fewer than n pigeons are roosting in n pigeonholes, then at least
one pigeonhole is unoccupied.
3. Look at Theorem 4.1(ii).
4. This is similar to Example 4.2.
7. A bipartite graph will contain no K3 ; what is the bipartite subgraph of
K2R(m,n)−2 with the most edges?
9. Use induction.
Chapter 5
1. Look at a Venn diagram.
2. One way is to prove that Dn+1 is odd if and only if n is even.
3. There are two cases: the previously vacant chair remains vacant or not.
5. Try induction.
Hints for Problems 379
Chapter 6
P∞
1. Write fb (x) = k=0 (a0 + a1 + · · · + ak )xk , multiply both sides by 1 − x,
and collect like terms.
Chapter 7
n
6. Use the explicit value for 2 and the fact that xk − y k is divisible by
x − y.
Chapter 8
4. Consider for any i, j in S the permutation σj ◦ σi−1 .
15. The eight permutations of D4 are the four rotations that were found
in the previous problem, together with the four reflections (13)(45)(68),
(16)(27)(38), (18)(25)(47), and (24)(36)(57).
380 Introduction to Combinatorics
Chapter 9
1. Simply modify the proof for the existence of a maximal element.
2. The Hasse diagram has an edge between x and y provided that there
is no element between them. What sort of relationships would three
mutually-adjacent vertices require?
3. Consider B4 where the set of four elements is the set of four primes
whose product is n.
Chapter 10
3. (iv) Remember that the sum of the degrees is even.
Chapter 11
2. (i) Consider any two adjacent vertices. Use the fact that they can have
no common neighbor.
(ii) Consider any two adjacent vertices x and y and form a new graph
by identifying them (two vertices in the new graph are adjacent if and
only if they were adjacent in the old graph; all vertices adjacent to x or
y are adjacent to the new vertex).
Hints for Problems 381
6. (i) First, solve the problem for n = 1. To solve the general case, treat
Kn,2n,3n as n copies of K1,2,3 together with further edges.
8. Show that any two vertices in the center of a tree are adjacent.
Chapter 12
2. See the part of the text preceding the theorem.
Chapter 13
1. What is the (1, 2) entry?
3. Use induction on k.
4. If you take the set all integers modulo a prime (or more generally the set
of all members of a finite field) and multiply by one non-zero member,
you get a permutation of the same set.
Chapter 14
1. Any two blocks have intersection size 2. Assume the treatments are
1, 2, 3, 4, 5, 6, 7. Consider the blocks that contain 1. Without loss
of generality, start with 1234. The second containing both 1 and 2
may as well be 1256 (if, for example, it is 1257, the permutation (67)
is an isomorphism). Show that the other blocks containing 1 are now
determined up to isomorphism (what are they?). Continue from there.
2. The proof of part (ii) is a generalization of Example 13.2.
3. The dual of a linked design must be balanced.
7. Use Exercise 14A.2 and Exercise 14A.9.
11. Divide the riders into two groups of 7. In the first seven heats, riders 1
through 7 meet each other once each.
Chapter 15
1. Use the matrix A found in part (i): show first that A×[an−1 an an+1 ]T =
[an an+1 an+2 ]T using the recurrence.
Solutions to Problems
Chapter 1
1. Suppose ρ is reflexive and circular.
xρy and yρz ⇒ zρx.
(i) Say xρy is true. We know yρy is true. Using the above equation
with z = y,
xρy ⇒ xρy and yρy ⇒ yρx.
So ρ is symmetric.
(ii) Apply symmetry to the equation:
xρy and yρz ⇒ zρx ⇒ xρz.
So ρ is transitive.
3. We use the fact that (n − 1)2 ≥ 2 when n ≥ 3. (In fact (n − 1)2 > 2 for
these values.) Therefore n2 − 2n + 1 ≥ 2 and n2 ≥ 2n − 1 + 2 = 2n + 1.
We proceed by induction on n. The result 2n ≥ n2 is true for n = 4
(both sides = 16). Assume n ≥ 4 and 2n ≥ n2 . Then
4. There must be at least two people. The result is true for 2 (the second
person, the man, is directly behind the first person, the woman). As-
sume it is true for n people. Consider any line on n + 1 people with
a woman in front and a man at the back. If the nth person is a man,
then by the induction assumption the required configuration (man di-
rectly behind woman) occurs somewhere in the first n places. If not,
the positions n and n + 1 provide the configuration.
383
384 Introduction to Combinatorics
6. Say there are v vertices. No vertex has degree greater than v − 1 or less
than 0. So, if they are all different, there must be one vertex of each
degree 0, 1, 2, . . . , (v − 1). The vertex of degree (v − 1) must be adjacent
to every other vertex, but it cannot be adjacent to the one of degree 0.
7. (i) 4; (ii) 4.
Chapter 2
1. Write an for the number of positive n-digit integers with all digits dis-
tinct. If n > 10, there are no such integers. Otherwise, there are nine
choices for the first digit (you cannot start with 0), 9 for the second, 8
for the third, . . . , and (11 − a) for the ath place. So an = 9 × P (9, n − 1).
So the number of positive integers with all digits distinct is
a1 + a2 + . . . + a10
= 9[P (9, 0) + P (9, 1) + . . . + P (9, 9)]
= 9[1 + 9 + 72 + 504 + 3, 024 + 15, 120 + 60, 480 + 181, 440
+362, 880 + 362, 880]
= 9 × 986, 410
= 8, 877, 690.
There are just as many negatives, and do not forget 0. So the answer is
17,755,381.
6. There are several examples; pappa and pops are both colloquially used
to refer to one’s father, and there are only 10 distinct rearrangements
of pappa compared to 12 for pops. Now that you have looked up the
answer, try to find some words (not necessarily so similar) on your own.
8. Write On and En for the numbers of subsets of an n-set of odd and even
orders, respectively. Then
n n
X n X n
On = , En = .
k k
k=0,k odd k=0,k even
Pn
From Corollary 2.3.3, k=0 nk (−1)k = 0. The terms in this sum are
n n
X n X n
= ,
k k
k=0,k odd k=0,k even
Pn
or On = En . From Corollary 2.3.2, k=0 nk = 2n , that is On + En =
10. (i) The 27 letters consist of 7 As, 6 N s, 5 Bs, 4 D’, 2 Ss, and one each
of I, T, R. So the number of rearrangements is
27!
− 1 = 520, 951, 478, 183, 135, 999.
7!6!5!4!2!
(We subtract 1 because rearrangements were called for, so the original
ordering is not included.)
(ii) Similarly we get
24!
− 1 = 62, 336, 074, 312, 511, 999.
6!4!4!3!2!2!
11. In the first case, the eight people can be seated in 7! ways. In the second
case, we seat one group first (in 3! ways), and then intersperse the others
between them in 4! ways, so there are 3!·4! = 144 arrangements. In the
last case, we seat the diplomat last, in one of thetwo endpoints or one of
the seven positions between two of the others; this gives us 9·144 = 1296
seating arrangements.
12. Clearly we must choose one person from each of n − 1 pairs, and no one
from the last pair. There are C(n, 1) = n ways to choose the pair that
will be neglected, and there will then be 2n−1 ways to choose one of
the two members of the n − 1 other pairs. So we have n·2n−1 possible
committees.
13. We take the cases one at a time. Practically speaking, there are three
cases; no vegetarian restaurants, no meat-only restaurants, and both.
The case “both” means we have one vegetarian and one meat-eater,
so we must stick to one of the five restaurants with omnivorous offer-
ings. This means that we can choose the friends in C(3, 1)·C(2, 1) = 6
ways, and any of the five restaurants will work, for 30 possibilities.
The “no-meat-only” case means that we exclude the meat-eaters but
not the vegetarians; there are C(8, 2) = 28 choices of two friends and
eight restaurants, so there are 224 possibilities. The “no-veg-only” case
means that we exclude the vegetarians but not the meat-eaters; there
are C(7, 2) = 21 ways to pick the friends, and seven restaurants accept-
able to these friends, for another 147 possibilities. Altogether, then,
there are 401 possibilities.
386 Introduction to Combinatorics
Chapter 3
1. As we saw, P (1) = 0.2, P (2) = P (3) = P (4) = P (5) = P (6) = 0.16.
So the probability of a roll of 4 or less is P (1) + P (2) + P (3) + P (4) =
0.2 + 0.16 + 0.16 + 0.16 = 0.68.
2. We shall write the outcomes in the form An, where A is H or T , the
result of flipping the quarter, and n = 0, 1 or 2, the number of heads on
the pennies. The sample space is {H0, H1, H2, T 0, T 1, T 2}. The tree
diagram is
0
1
H 2
T 0
1
2
3. The diagram is
A
6 24
1 3 5
B C
9. Let N (S) denote the sum of the elements of a 4-set S, and let T be the
set of all 4-subsets of {0, 1, . . . , 9}. T has 10
4 = 210 elements. Write
Tn for the set of all members S of T with N (S) = n. The smallest
possible value of n is 6, and the largest is 30. there is only one 4-set
with sum 6, namely {0, 1, 2, 3}, one with sum 7 ({0, 1, 2, 4}), one with
388 Introduction to Combinatorics
sum 29 ({5, 7, 8, 9}), and one with sum 30 ({6, 7, 8, 9}). So the remaining
206 4-subsets have sums from 8 to 28. If the 21 sets T8 , T9 , . . . , T28 each
contains nine or fewer elements, they would total at most 189 members
between them, less than 206, which is impossible. So some Tn has 10 or
more members.
Chapter 4
Sn
1. (i) Say S = i=1 Ai . If each Ai satisfies |Ai | ≤ m then |S| ≤ nm, a
contradiction. So there is at least one i such that |Ai | > m.
(ii) If ai ≤ nb for all i then ni=1 ai ≤ b, a contradiction.
P
Pn
(iii) If ai > nb for all i then i=1 ai > b, a contradiction.
(iv) If ai ≥ nb for all i then ni=1 ai ≥ b, a contradiction.
P
2. The worst case is when all boxes but one contain 1 object and the
remaining box contains N − (B − 1) = N − B + 1. So at least N − B + 1
must be chosen.
3. For (i) and (ii), suppose the statement is false. Then there are at most 12
people belonging to each of only 12 signs, so there are only 144 people.
But we know that there are 145 people; this contradiction establishes
the results. For (iii), there are 122 = 144 possible pairs of signs, and
145 people, so there are at least two people who have the same pair of
signs.
4. Suppose no two sets contain the same number of entries. At the very
least, one will be empty, one will have order 1, one 2, . . . and the total
number of entries is
p(p − 1)
n = 0 + 1 + . . . + (p − 1) = .
2
So n ≥ p(p−1)
2 is a necessary condition for all the Ai to be of different
size. (If n is larger, simply add more members to the largest set.) On
the other hand, if n = p(p−1)
2 + t, such a set A exists—for example,
But finally
Ap = {p − 1, 2p − 1, . . . , (p + t)p − 1}.
p(p−1)
So n ≥ 2 is necessary and sufficient.
Solutions to Problems 389
and
n(n − 1)2 (2t + 1)4t2
== t3 + 12 t2 .
=
8 8
So the two are equal.
When n is even, say n = 2t,
$ $ 2 %%
n n−1
= t(t2 − t) = t3 − t2 ,
2 2
but
n(n − 1)2 2t(2t − 1)2 8t3 − t2 + 2t
3 2 t
= = =t −t + ,
8 8 8 4
with equality if and only if ⌊ 4t ⌋ = 0, that is t < 4. So the two expressions
are equal unless n is even and n ≥ 8.
390 Introduction to Combinatorics
Chapter 5
1. (B ∩ C) ∪ (B ∩ C) = C, and the two sets on the left are disjoint, so
|B ∩ C| + |B ∩ C| = |C|. Similarly (A ∩ B ∩ C) ∪ (A ∩ B ∩ C) = A ∩ C
and |A ∩ B ∩ C| + |A ∩ B ∩ C| = |A ∩ C|. So
|A ∪ C|
= |A| + |C| − |A ∩ C|
= |A| + (|B ∩ C| + |B ∩ C|) − (|A ∩ B ∩ C| + |A ∩ B ∩ C|).
3. Suppose the people are numbered 1 to n and the chairs are numbered
0 to n; say person x occupies seat x initially and seat x′ after supper.
Suppose the previously vacant chair remains vacant. Then (1′, 2′, . . . , n′)
is a derangement of (1, 2, . . . , n). This can occur in Dn ways. To handle
the other case, 0′ is the number of the chair that is unoccupied after
supper; (0′, 1′, 2′, . . . , n′) is a derangement of (0, 1, 2, . . . , n). This can
occur in Dn+1 ways.
Chapter 6
an xn = n n
P P P
2. n≥0 n≥0 c1 n(rx) + n≥0 c0 (rx) . The second sum is
clearly c0 /(1 − rx); the first requires differentiation. We use
d P n n d
dx n≥0 c1 r x = dx c1 /(1 − rx).
Solutions to Problems 391
This gives us n≥0 c1 rn nxn−1 = rc1 /(1 − rx)2 . Multiplying both sides
P
Now
∞ ∞ ∞
X xn X xn X xn+1
nDn−1 = Dn−1 = Dn = xE(x)
n=2
n! n=2
(n − 1)! n=1 n!
and
∞ n ∞
X
nx
X (−x)n
(−1) = = e−x − (1 − x)
n=2
n! n=2
n!
(it is the expansion of e−x with the first two terms omitted). So
e−x
E(x) = xE(x) + e−x + x − 1, E(x) = − 1.
1−x
Chapter 7
n o
2k+1
6. Let n = 2k + 1; then we know 2 = 22k − 1 = 4k − 1k . Now, the
polynomial xk − y knis divisible
o by x − y; in this case, using x = 4 and
y = 1, we see that 2k+1
2 is divisible by 4 − 1 = 3 as required.
392 Introduction to Combinatorics
Chapter 8
2. Say a, b ∈ G and x, y ∈ H. Then ab = ba and xy = yx. So
and z22 . We have then C(z1 , z2 , z3 , z4 ) = (z14 + 8z1 z3 + 3z22 )/12 for the
cycle index. Substituting k for each of the zi s gives us (k 4 + 11k 2 )/12.
Chapter 9
2. Take the poset X with at least three different elements x, y, and z. If
any two of these are incomparable, we cannot have the three mutually
adjacent elements required to form a K3 , so without loss of generality
assume x ≻ y. (If not, rename x and y.) Similarly, assume x ≻ z
(renaming if necessary). Now, either z ≺ y or y ≺ z. If z ≺ y, then we
have z ≺ y ≺ x, so that x does not cover z; thus there is no line from x
to z in the Hasse diagram. If y ≺ z, then there is no line from x to y.
3. Suppose n = p1 p2 p3 p4 , and consider the power set of the set {1, 2, 3, 4}.
The isomorphism σ will map the set A of this power set to the divisor
d of n precisely when d is the product of the primes whose subscripts
correspond to the elements of A. Thus, σ({2, 4}) = p2 p4 , and so forth.
Consider two subsets A1 and A2 where σ(A1 ) = d1 and σ(A2 ) = d2 ;
if A1 ⊂ A2 , then each prime factor of d1 is also a factor of d2 , so that
d1 ≺ d2 in Dn . In the same way, if we have any two divisors d1 and d2
of n, where d1 ≺ d2 , then σ −1 (d1 ) ⊂ σ −1 (d2 ) since each prime factor of
d1 is a factor of d2 .
7. We can find antichains of five elements, but not of six. We see that
{a, b, d, e, f } (the antichain of all maximal elements) works; as there are
only four minimal elements, the antichain of minimal elements is not a
largest-sized antichain. But we can take {a, b, d, j, k} and {a, b, h, j, k}.
394 Introduction to Combinatorics
Chapter 10
1. Reducing the degree sequence, we get
(5, 5, 5, 3, 2, 2, 1, 1) ⇒ (4, 4, 2, 1, 1, 1, 1)
⇒ (3, 1, 0, 0, 1, 1) = (3, 1, 1, 1, 0, 0)
⇒ (0, 0, 0, 0, 0)
which is not valid (one vertex has degree 3, but there is only one other
non-isolate).
2. ⌈ 12 vδ(G)⌉
3. (i) Here are P4 and C5 and their complements. The complements have
been relabeled to exhibit the isomorphism.
A A
E B C D
B
A B C D B D A C
D C E B
P4 P4 C5 C5
(ii) Suppose vertex x is an isolate. In the complement, x is adjacent
to every other vertex, so there are no isolates.
(iii) The degree sequence consists of five numbers, between 1 and 3
inclusive, and the number of 3s equals the number of 1s. The
possibilities are (3, 3, 2, 1, 1), (3, 2, 2, 2, 1) and (2, 2, 2, 2, 2). A short
exhaustive search shows there is exactly one graph with the first
and third sequences, namely G (below) and C5 ; this uniqueness
means that they must be self-complementary. The other sequence
is realized by two non-isomorphic graphs, which are complements
of each other (H and H, see below). So G and C5 are the only
solutions.
G H H
Solutions to Problems 395
Plugging these two results into the equation we get the result.
7.
8. D(G) is the largest distance between any two vertices in G; say D(x, y) =
D(G). R(G) is the smallest value of ε; let z be a vertex for which
ε(z) = R(G). As R is a distance between some two vertices, R ≤ D.
But by definition D(z, t) ≤ ε(z) = R(G) for every vertex t, so D(G) =
D(x, y) ≤ D(x, z) + D(z, y) ≤ 2R(G).
396 Introduction to Combinatorics
Chapter 11
1. You would treat a loop as adding 2 to the degree of its vertex. They do
not need special treatment in Euler walks—you can traverse the loop
when you pass through the vertex. As roads, a loop might represent a
crescent. Or a snowplow might need to clear a large circular driveway
on city property.
3. Examples for the first two parts:
(i) (ii)
where the shaded sections denote the Ti . Then each Ti is a tree. Ti may
just be the vertex xi , in which case xi is a vertex of degree 1 in T . If
Ti is not a single vertex, its vertices of degree 1 (other than xi ) will all
398 Introduction to Combinatorics
11. If a tree has v vertices, the sum of the degrees is 2v−2. So Problem 11.10
told us the number of trees on v vertices with a given set of degrees. To
find the total number of trees, we sum over all possible degree sets. So
the sum is
Solutions to Problems 399
X (v − 2)!
(d1 − 1)!(d2 − 1)! . . . (dv − 1)!
d1 +d2 ...+dv =2v−2
X (v − 2)!
k1 !k2 ! . . . kv !
k1 +k2 ...+kv =2v−2
Chapter 12
1. The codewords correspond to the vertices of the subgraph, but there
is no obvious relationship to the edges. However, the distance between
two words equals the distance between the corresponding vertices in the
underlying hypercube.
3. Minimum distance is 4. So the code can detect three errors and always
correct one.
5. If a code has minimum distance 2n or smaller, one can select two words
A and B that differ in at most 2n positions. Say S is the set of positions
where they differ. Consider a received word that is the same as A (and
B) is those positions where the two are the same, is the same as A in n
of the positions where they differ, and is the same as B in the remaining
positions. There is no way to know whether to decode this word to A
or to B. (Note: If the distance is smaller than 2n, it is tempting to
say, “decode to the codeword that gives fewer errors,” but there is no
guarantee that this will be correct.)
400 Introduction to Combinatorics
Chapter 13
2. One example is
1 4 6 5 3 2
4 2 5 6 1 3
2 5 3 1 6 4
6 3 1 4 2 5
3 6 4 2 5 1
5 1 2 3 4 6
5. One solution is
1 2 3
4
1 1 1 2 2 2 3 3 3
1 2 3 1 2 3 1 2 3
6. (i)
1 2 3 3 1 2 2 3 1
1 3 2 3 2 1 2 1 3
(ii) No. You would need orthogonal Latin squares of order 6.
(iii) Use 3 MOLS of order 4 to construct a 5 × 16 orthogonal array, and
use the columns as the codewords. Let’s say two codewords are properly
separated if they have exactly one entry in common.
Suppose the entries in position (i, j) in the three squares are a, b, c,
respectively. So one codeword is (i, j, a, b, c). There will be three other
columns corresponding to cells in row i, and none will have a j in position
2 (a j there would mean the corresponding entry was also in the (i, j)
position, and there is only one entry per cell), or an a in position 3 (that
would mean two entries a in row i of the first square). Similarly, none
of them has a b in position 4, or a c in position 5. So our codeword
is properly separated from the three other words with i in position 1.
In the same way we see that our codeword is properly separated from
the three other words with j in position 2, the three other words with a
in position 3, the three other words with b in position 4, and the three
other words with c in position 5. Moreover our reasoning shows that all
15 of those codewords are different. Since there are only 16 codewords,
we have shown that (i, j, a, b, c) is properly separated from all the other
codewords.
But (i, j, a, b, c) is completely general. So every pair of codewords is
properly separated.
Solutions to Problems 401
7. (i) The (1, 4) entry must be 4 (in order to complete column 4). So the
first row is 12345. So the (5, 4) entry must be 3. Now consider the
completion of row 5; a 2 and a 5 are needed and the 5 cannot be in
column 5, so row 4 is 34512. Similarly row 3 must be 45123. The array
looks like
1 2 3 4 5
1 3
4 5 1 2 3
3 4 5 1 2
4 5
The 5 in row 2 must be in column 1, and to complete column 3 the (2, 3)
entry must be 2. So row 2 is 51234. Now the array can be completed:
1 2 3 4 5
5 1 2 3 4
4 5 1 2 3
3 4 5 1 2
2 3 4 5 1
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
5 1 2 3 4 5 1 4 3 2 4 1 5 3 2
(ii) 4 5 1 2 3 3 5 1 2 4 3 5 1 2 4
3 4 5 1 2 2 4 5 1 3 5 4 2 1 3
2 3 4 5 1 4 3 2 5 1 2 3 4 5 1
Chapter 14
1. (i) From the hint, there are blocks 1234 and 1256. There is one further
block containing 13. Since the intersection size is 2, 4 is not included,
and not both of 5 and 6 can occur, so there must be a final 7 (no other
symbols are available). The block is either 1357 or 1367. We’ll choose
1357 (otherwise, use the isomorphism (56)). The fourth block containing
1 can only be 1467.
There are two further blocks containing 2. Since 2 and 7 have not
occurred together, 7 must be in both blocks. One must contain 3 and
the other contain 4 (234 cannot occur together). We either have 2357
and 2367. But 2357 is impossible (357 has already been used) so 2367
is block, and so is 2457 (in order for 2 to occur twice with every other
symbol). The final block is 3456. So we have blocks
(ii) D has precisely seven triplets: (012), (034), (056), (078), (0910),
(01112), (0134). Da st also has seven triplets: (016), (024), (035), (125),
(134), (236), (456). Any isomorphism would have to carry one set of
triples into the other; this is clearly impossible.
9. (i) Say one line has k points. From the axioms, every other line contains
precisely one of these, so there are k + 1 lines in total. If some other line
had h points, there would be h + 1 lines in total. So h = k.
(ii) There are k points per line, and k + 1 lines; each point is on two
lines, so there are v = 21 k(k + 1) points in all. Call them x1 , x2 , . . . , xv .
Say the first line is
x1 , x2 , x3 , . . . , xk ;
the second line has one point in common with this, so (up to permutation
of names of points) it is
x1 x2 x3 ... xk
x1 xk+1 xk+2 ... x2k−1
x2 xk+1 x2k ... x3k−2
x3 xk+2 x2k ... x4k−3
... ...
xk x2k−1 x3k−2 ... xv .
1 2 3 4 5
1 6 7 8 9
2 6 10 11 12
3 7 10 13 14
4 8 11 13 15
5 9 12 14 15
10. You would have λ(2k − 1) = k(k − 1), so λ = k(k − 1)/(2k − 1). Now
2 2k−1
clearly 2k > 2k − 1 > 2k − 2, so k−1 > k(k−1) > k2 , and k−1 2k−1
2 < k(k−1) <
k k−1 k
2 . So λ would lie between 2 and 2 , and there is no integer in that
range.
404 Introduction to Combinatorics
11. Say m and v are coprime. Then the integers m, 2m, . . . , (v − 1)m are all
different modulo v, and are congruent to 1, 2, . . . , v − 1 in some order.
Moreover, of the pairs with difference d (mod v) are {x1 , y1 }, {x2 , y2 },
. . . , {xλ , yλ }, then there are precisely λ pairs in mD with difference md,
namely, {mx1 , my1 }, {mx2 , my2 }, . . . , {mxλ , myλ }. On the other hand,
if m and v are not coprime, there may be x and y in D such that mx
and my are congruent mod v, or mx could be zero.
1 2 3 4 5 6 7
2 3 4 5 6 7 1
4 5 6 7 1 2 3
A B C D E F G
A B C D E F G
B C D E F G A
.
D E F G A B C
∗ ∗ ∗ ∗ ∗ ∗ ∗
1 2 3 4 5 6 7 A B C D E F G
2 3 4 5 6 7 1 B C D E F G A
.
4 5 6 7 1 2 3 D E F G A B C
A B C D E F G 6 7 1 2 3 4 5
(ii) There is only one way to pair up the heats in our solution to satisfy
the conditions of this part: heats 1 and 9 are paired; then 2,10; 3,11;
. . . ; 6,14; 7,8.
Solutions to Problems 405
Chapter 15
0 1 0
1. (i): A = 0 0 1 .
−2 1 2
1 1 1
(iii): P = 1 −1 2 .
1 1 4
2. The induction step: Assume An−1 (i, j) is the number of ways to walk
from i to j in n − 1 steps for any i and j. Then let i, j be given and
determine An (i, j). For each neighbor k of vertex j, An−1 (i, k) is the
number of ways to walk from i to k in n − 1 steps. The (i, j) entry
of An , by the definition of matrix multiplication, is the sum over all k
adjacent to j of An−1 (i, k); this adds up all walks of length n − 1 from
i to a neighbor of j, which correspond to walks of length n from i to j.
5. This is true if the matrix has only non-negative entries (as an adjacency
1 1
matrix does). However, if we allow negative entries, the matrix
−1 1
is a counterexample.
√
6. The approximation is (2/e)n 2πn which goes to 0 as n → ∞.
406
References
[1] H. L. Abbott, Lower bounds for some Ramsey numbers, Discrete Math.
2 (1972), 289–293.
[2] W. S. Anglin and J. Lambek, The Heritage of Thales, 5th ed. (Springer-
Verlag, New York, 1995).
[3] H. Anton, Elementary Linear Algebra, 9th ed. (Wiley, New York, 2005).
[4] K. Appel and W. Haken, (October 1977), Solution of the Four Color
Map Problem, Scientific American 237 (1977), 108–121.
[5] M. E. Baron, A note on the historical development of logic diagrams,
Math. Gaz. 53 (1969), 113–125.
[6] E. T. Bell, Men of Mathematics, 5th ed. (Simon & Schuster, New York,
1937).
[7] M. Bellis, Timeline: Biography of Samuel Morse 1791–1872,
http://inventors.about.com/od/mstartinventors/a/samuel morse.htm
407
408 Introduction to Combinatorics
417
418 Introduction to Combinatorics
Euler, 193–199
simple, 181
weak induction, 313
wheel, 25