3. Applications of combinations and combinations with repetition#
The previous notes introduced strings, permutations, and combinations. The central modeling questions were whether order matters and whether a selection may repeat an object. In these notes we use those questions to count lattice paths and repeated-letter anagrams. We then develop the remaining basic model: unordered selections in which repetition is allowed.
After studying these notes, you will be able to do the following.
Define a northeast lattice path.
Encode a two- or three-dimensional lattice path as a string of steps.
Count arrangements with repeated symbols using multinomial coefficients.
Recognize an unordered selection with repetition as a multiset.
Use stars and bars to count multisets and nonnegative integer solutions.
Combine several counting models in a single problem.
3.1 Choosing the correct model#
We begin with a selection of
| Order matters? | Repetition allowed? | Standard model | Number of outcomes |
|---|---|---|---|
| Yes | Yes | Strings | |
| Yes | No | Permutations | |
| No | No | Combinations | |
| No | Yes | Multisets |
The previous notes established the first three formulas. Stars and bars will
establish the last formula later in these notes. In every row,
The words used in a problem do not determine the row. The word “choose,” for example, does not automatically mean that order is irrelevant. Choosing a president and then a vice president creates an ordered pair of people, while choosing two ordinary committee members creates an unordered subset.
A formula should not come from keywords alone. We first state what information determines one outcome. Next, we decide whether changing the order or repeating an object changes that outcome.
3.2 Lattice paths in the plane#
An integer lattice point in the plane is a point
Every such path must use exactly
Figure 3.1 shows one path together with the step string that records it.
The correspondence between paths and step strings goes in both directions.
A path determines its string by recording its steps, and a string with
For nonnegative integers
Each path determines a unique length-
A path from RURRURRU. Its five copies of R and three copies of
U verify that it has the required endpoint.
The same idea counts paths between two other lattice points. To move from
How many northeast lattice paths go from
3.3 Three-dimensional paths and multinomial coefficients#
The string model extends naturally to higher dimensions. In three dimensions,
the positive coordinate steps are
We begin with a concrete path and build its step string one kind of step at a time.
How many positive-coordinate lattice paths go from
Solution: Throughout this example, we display
This is a multistep operation. In the first stage, we choose which two of the
six positions will contain
This is only a partial string, not yet a complete path.
In the second stage, we choose three of the four positions that are still
empty and put
One position remains, so it must contain
If we record this forced final stage as a choice, it has
For a general three-dimensional endpoint
The same position-filling procedure works for any number of symbol types.
A length-
For
For
The stages described above have
To apply this formula to paths, we write
3.4 Anagrams with repeated letters#
An anagram of a word is a rearrangement of all of its letters. If all
letters are distinct, there are
If a nonempty word of length
An anagram is exactly a string with a prescribed number of copies of each
letter, so the result follows from Theorem 3.5. Here is a
second explanation of the denominator. Temporarily distinguish equal letters
with labels. For instance, we write the three copies of
The word BANANA has six letters: three copies of A, two
copies of N, and one copy of B. Therefore it has
We can also choose the three positions for A, then two of the three
remaining positions for N; the last position contains B.
This gives
If two people, colors, or roles are distinct in the outcome, exchanging them does not create the same outcome. A factorial belongs in the denominator only when permuting the corresponding labeled copies leaves the underlying outcome unchanged.
3.5 Combinations with repetition#
A doughnut shop offers ten types of doughnuts and has an unlimited supply of each type. How many ways are there to buy six doughnuts?
An outcome is not a string of six successive purchases. For example, buying a glazed doughnut and then a chocolate doughnut gives the same purchase as buying the chocolate doughnut first and the glazed doughnut second. Order does not matter. On the other hand, the buyer may purchase several doughnuts of one type, so the model allows repetition.
This is an unordered selection with repetition, also called a multiset.
One way to record the purchase is by a multiplicity vector
3.5.1 The stars-and-bars encoding#
We encode a nonnegative solution of
is the number of stars before the first bar; is the number of stars between bars and ; is the number of stars after the last bar.
For example, when
Figure 3.2 displays the same encoding with the four groups of stars separated visually.
Bars may be adjacent, because we may select a type zero times. A bar may
also occur first or last, corresponding respectively to
For integers
Every solution determines one string containing
The string has
If
Let us return to the shop with ten types of doughnuts. The multiplicities satisfy
The value
When
How many nonnegative integer solutions are there to
3.6 Combining models: nonadjacent letters in ARKANSAS#
We finish with a problem that uses repeated-letter anagrams, the product rule, and an ordinary combination.
How many anagrams of ARKANSAS have no two copies of A
adjacent?
Solution: The word contains three copies of A, two copies
of S, and one copy each of R, K, and N.
We first remove the three copies of A. Next, we arrange the five
remaining letters RKNSS. Because the two copies of S are identical,
the number of base arrangements is
Every base arrangement has six gaps: before the first letter, between each
pair of consecutive letters, and after the last letter. To prevent adjacent
copies of A, we place at most one A in each gap. We must choose
three distinct gaps from the six available gaps, which can be done in
By the product rule, the requested number of anagrams is
This construction counts each valid anagram exactly once. Given a valid
anagram, deleting its three copies of A recovers one unique base
arrangement of RKNSS; the former locations of the copies of
A recover the three chosen gaps.
Figure 3.3 illustrates the gap construction for one base arrangement.
There is a useful consistency check. If we allowed adjacent copies of
A, stars and bars would distribute the three indistinguishable copies
among the six gaps with repetition. This gives
3.7 A counting checklist#
The main ideas in these notes are different views of the same objects. A lattice path is a step string; an anagram is a string with prescribed symbol multiplicities; a multiset is a multiplicity vector; and a multiplicity vector is a stars-and-bars string.
When solving a new problem, we can organize the model with the following checklist.
What information determines one outcome?
Does order matter, and does the model allow repetition?
Which familiar encoding fits: a string, subset, multiset, integer vector, or lattice path?
Why is the encoding reversible, or why is any overcounting factor constant?
Which formula corresponds to that model?
The formulas developed here are
3.8 Further reading#
The course resources page links to the books used as references for these notes. Applied Combinatorics, Sections 2.5 and 2.7, covers lattice paths and multinomial coefficients. Counting Rocks!, Sections 3.5.1, 4.1, 4.5, and 4.6, covers multisets, stars and bars, lattice paths, and repeated-letter anagrams.