This tutorial describes some common combinatorial problems and approaches to solve them. We consider counting with distinct, non-repeatable elements, counting with an infinite number of distinct element types, and counting with non-distinct (identical) elements.
Counting with Distinct Elements
Given: A set of
distinct elements.
Task: Count the number of ways to list the
elements.
This task is equivalent to finding how many orderings there are of the
elements. Think of the task this way: Imagine that you have
people and you want to This task is lik find how many different ways there are to line these
people up to get lunch from a buffet. Order matters here, because the person at the end of the line will have to wait longer to get their food.
To solve this task, we think of
slots, which represent the
possible positions in the line:
![[comb-Z-G-8.gif]](comb-Z-G-8.gif)
Now we consider how many choices we have for each slot. We have
choices of people to put in the first slot,
choices of people to put in the second slot, and so on, until we finally have
choice for the final (
) slot:
![[comb-Z-G-13.gif]](comb-Z-G-13.gif)
The product rule applies here, so there are
![[comb-Z-G-14.gif]](comb-Z-G-14.gif)
ways to order these
elements.
Given: A set of
distinct elements.
Task: Count the number of ways to list
of the
elements.
In continuing with our lunch buffet example, imagine this task as such: There are only enough plates for
of the
people. How many ways are there to pick
people and line them up to eat at the buffet?
We solve this task in a way similar to the previous one. The only difference is that there are
slots:
![[comb-Z-G-23.gif]](comb-Z-G-23.gif)
Again, we fill in the slots from the available choices:
![[comb-Z-G-24.gif]](comb-Z-G-24.gif)
So the number of ways to perform these tasks is:
![[comb-Z-G-25.gif]](comb-Z-G-25.gif)
Notice that this is equivalent to
. This value is denoted by the special function
, which describes the number of
-permutations of
.
Given: A set of
distinct elements.
Task: Count the number of ways to make groups of size
from these
elements.
To answer this question, consider the solution to the previous task. In the previous task, we wanted to count the number of ways to pick
people to eat and then line these
people up at the buffet. In this task, we are just asking how many possible groups of size
we can create, and we don't care about ordering them in a line to eat. So, to solve this task, we observe that for each group in the previous solution, there are
ways to line those people up to eat. Because we don't care about ordering in this task, we can divide the answer from the last task by
. So the answer is:
![[comb-Z-G-38.gif]](comb-Z-G-38.gif)
This value is denoted by the special function
, which describes the number of
-combinations of
. There is also a equivalent special notion
, which is read ``
choose
''.
Given: A set of
distinct elements and
boxes that can hold
elements (and
).
Task: Count the number of ways to fill the
boxes with the
elements.
In this task, we have
slots (boxes). Now, the order of the elements within the boxes does not matter. The only thing that matters is the choice of which elements go into which box. To solve this task, we first choose
elements to go into the
box. Now we have
elements left to place in
boxes. Next, we choose
elements to go into the
box, and so on. The picture looks like this:
![[comb-Z-G-58.gif]](comb-Z-G-58.gif)
This resultant formula is equivalent to
. To see why this is true, consider the expansion of the above picture:
![[comb-Z-G-60.gif]](comb-Z-G-60.gif)
Counting with Distinct Elements and Repetion
In the previous section, we considered tasks of counting distinct elements without repetition. In this section, we consider counting distinct elements with repetition. For these problems, we have an infinite number of elements, and each element has a particular type.
Given: A set of
distinct element types.
Task: Count the number of ways to list
elements, when each element can have one of the
types.
To solve this task, we can again use our slot diagram. There are
slots, and for each slot, we can choose any of the
available element types:
![[comb-Z-G-66.gif]](comb-Z-G-66.gif)
So there are
ways to list
elements, where each element takes one of the
types.
As an example, imagine you own a sports team. In front of your stadium, you have 7 flag poles. Your team colors are red, yellow and white. How many ways are there to place red, yellow or white flags on your seven flag poles? In this case, the colors are
(3) and the flagpoles are
(7). So the answer is
.
Given: A set of
distinct element types.
Task: Count the number of ways to make a group of
elements, where each element has one of the
types.
This is the most difficult of the problems. Think of this task as assigning some number of
elements to have a particular type. Similarly, we can view this as assigning a value to each element type that corresponds to the number of elements that have that type. To model, this problem, we use the ``stars and bars'' method. A star (*) corresponds to one of the
elements. A bar (
) corresponds to a divider between element types. When modelling the problem, there will be
stars (one for each element) and
bars (because it takes
dividers to create
groups). So we have a total of
slots. The solution to the problem is simply the number of ways to select
of these slots into which we will place a star. [Equivalently, we can give the number of ways to select
of these objects to contain a bar.] So the answer is
. [Or, equivalently,
.]
Counting with Indistinct Elements
In the previous sections, we considered tasks of counting with distinct elements. In this section, we consider counting with indistinct (i.e., identical) elements
Given:
sets of
indistinct elements (
)
Task: Count the number of ways to list the
elements.
The difference between this task and the very first task is that some of the
elements are identical. Consequently, some of the listings are identical. To solve this task, we consider
slots. For each of the
sets, we choose
slots into which we will place that element type. So, the solution takes the form:
![[comb-Z-G-96.gif]](comb-Z-G-96.gif)
As we saw in a previous task, this is equivalent to
.