maths.freeCombinatorics & Graph Theory › 4. Counting › Combinations and Permutations

Combinations and Permutations

Investigation You have decided to decorate your magic wand with bands of different colored tape. You have 10 different colors to choose from, and you will use five of them to create five different stripes of color.

Section Preview

Investigation

You have decided to decorate your magic wand with bands of different colored tape. You have 10 different colors to choose from, and you will use five of them to create five different stripes of color. How many different wand designs are possible?

The product principle gives us a way to count the number of outcomes when each outcome is made by combining smaller pieces. A typical example of this is to count the number of three-letter words; each outcome (word) we count is made up of a combination of three smaller pieces (letters). Since there are 26 choices for each smaller piece, there are \(26\cdot 26\cdot 26 = 26^3\) possible outcomes.

The product principle does not require that each piece that is being combined be chosen from a set of the same size. We will use this observation to create a standard way to count outcomes when the pieces are chosen from a fixed set, but without allowing for any piece to be used more than once. For example, we can ask how many 3-letter words there are that contain distinct letters.

These arrangements are called permutations. We will also consider another counting technique where we count combinations, which is related but counts something different. We will explore how these two counting techniques are related and how they can be used to solve a wide range of counting problems.

Counting Sequences

A permutation is a (possible) rearrangement of objects. For example, there are 6 permutations of the letters a, b, c: \[abc, ~~ acb, ~~ bac, ~~bca, ~~ cab, ~~ cba\]. In terms of our discrete structures, each permutation is really a sequence or tuple of a fixed length.

We know that we have them all listed above there are 3 choices for which letter we put first, then 2 choices for which letter comes next, which leaves only 1 choice for the last letter. The multiplicative principle says we multiply \(3\cdot 2 \cdot 1\).

Example

How many sequences (permutations) are there of the letters a, b, c, d, e, f?

Solution

We do NOT want to try to list all of the length 6 sequences of these letters. However, if we did, we would need to pick a letter to write down first. There are 6 choices for that letter. For each choice of the first letter, there are 5 choices for the second letter (we cannot repeat the first letter; we are rearranging letters and only have one of each), and for each of those, there are 4 choices for the third, 3 choices for the fourth, 2 choices for the fifth, and finally only 1 choice for the last letter. So there are \(6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 720\) permutations of the 6 letters.

A piece of notation is helpful here: \(n!\), read \(n\) factorial, is the product of all positive integers less than or equal to \(n\) (for reasons of convenience, we also define 0! to be 1). So the number of permutations of 6 letters, as seen in the previous example is \(6! = 6\cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1\). This generalizes:

Sometimes we do not want to permute all of the letters/numbers/elements we are given.

Example

How many four-letter words can you make from the letters a through g, with no repeated letters?

Solution

This is just like the problem of permuting four letters, only now we have more choices for each letter. For the first letter, there are 7 choices. For each of those, there are 6 choices for the second letter. Then there are 5 choices for the third letter and 4 choices for the last letter. The total number of words is \(7\cdot 6\cdot 5 \cdot 4 = 840\).

This is not \(7!\) because we never multiplied by 3, 2, or 1. We could write it using \(7!\) though, if we cancel the 3, 2, and 1. Thus we could write the answer as \[\frac{7!}{3!} = \frac{7\cdot 6\cdot 5\cdot 4 \cdot \cancel{3} \cdot \cancel{2} \cdot \cancel{1}}{\cancel{3} \cdot \cancel{2} \cdot \cancel{1}} = 7 \cdot 6 \cdot 5 \cdot 4\].

Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.

Counting Sets

Let's consider another way to count sequences: First count sets, then arrange them.

Example

Your basketball team has 12 players. Assuming everyone can play every position, how many ways can you choose 5 players to be on the court at the same time?

Solution

This question is actually too vague. Do we mean how many ways can we select five players? Or do we mean how many ways can we pick five players to fill the five positions?I'm told the five positions are called point guard, shooting guard, small forward, power forward, and center. Who knew? Let's answer both of these questions.

First, if we just want to select five out of the 12 players, that is just like picking five out of 12 pizza toppings (although less delicious). We know that there are \(\binom{12}{5}\) ways to do this, and from Pascal's triangle we know that this is 792.

On the other hand, if we wanted to pick five players for the five different positions,... well, we could start by picking one of the 792 different sets of five players, and then permute them into the five positions. Of the five players on the court, we pick one of the five to be the point guard, then one of the remaining four to be the shooting guard, and so on. This gives us \(5\cdot 4\cdot 3\cdot 2\cdot 1 = 5!\) ways to arrange the players. So the total number of ways to pick five players for the five positions is \[\binom{12}{5}\cdot 5! = 792\cdot 120 = 95,040\].

Wait. We could have found that number directly. Without choosing the five players first, we have 12 choices for the point guard, then 11 choices for the shooting guard, and so on. So the total number of ways to pick five players for the five positions is simply the permutation \[P(12,5) = 12\cdot 11\cdot 10\cdot 9\cdot 8 = 95,040\]. Thank goodness that is the same answer!

The example above illustrates a second way to compute the number of \(k\)-permutations of \(n\) elements: First select which \(k\) elements will be in the permutation, then count how many ways there are to arrange them. Once you have selected the set of \(k\) objects, we know there are \(k!\) ways to arrange (permute) them. But how do you select \(k\) objects from the \(n\)? You have \(n\) objects, and you need to choose \(k\) of them. You can do that in \(\binom{n}{k}\) ways.

Using the multiplicative principle to combine the two steps, we get another formula for \(P(n,k)\): \[P(n,k) = \binom{n }{ k}\cdot k!\].

This is HUGE!

We have a closed formula for \(P(n,k)\) already. We can substitute that in: \[\frac{n!}{(n-k)!} = \binom{n}{k} \cdot k!\].

If we then divide both sides by \(k!\), we get a closed formula for \(\binom{n}{k}\).

Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.

The Quotient Principle

We have two ways to write the numerical relationship between the numbers of combinations and permutations. Using the product principle, we have, \[P(n,k) = \binom{n}{k} \cdot k!\] which can be rewritten as, \[\binom{n}{k} = \frac{P(n,k)}{k!}\]. This second formula suggests that there might be a quotient principle that we could use to justify it.

Let's think about what division means. One way to think of the division problem \(24 \div 6 = 4\), for example, is saying that if you have 24 things that you divide into groups of size 6, the number of groups will be 4.The other way to interpret this statement is that if you divide 24 things into six groups, then each group will have size 4, but this is less useful for what we will do.

Now let's look at all the 3-permutations of a set of size 4: For example, all the ways to make 3-letter words using the letters \(a, b, c, d\). We know the number of such words is \(P(4,3) = 4\cdot 3 \cdot 2 = 24\). It is helpful to actually list all these out.

\(abc\)\(acb\)\(bac\)\(bca\)\(cab\)\(cba\)
\(abd\)\(adb\)\(bad\)\(bda\)\(dab\)\(dba\)
\(acd\)\(adc\)\(cad\)\(cda\)\(dac\)\(dca\)
\(bcd\)\(bdc\)\(cbd\)\(cdb\)\(dbc\)\(dcb\)

Look at the first row. What do all these permutations have in common? These are exactly the permutations that use the letters \(a, b, c\) in different orders. It is not surprising that there are 6 of these, since the number of ways to arrange three elements is \(3! = 6\). Similarly, the second row has 6 permutations that use the letters \(a, b, d\) in different orders, and so on.

The point is, if we wanted to just count how many sets of three of the four letters we have, each set corresponds exactly to one of the rows in the table. There are 24 elements in the table, and 6 elements in each row, so there must be \(24 \div 6 = 4\) rows. And of course, we are not surprised because \(\binom{4}{3} = 4\).

A more mathematically rigorous explanation for this phenomenon is to use the language of equivalence relations and partitions from . We start with permutations, and then we define an equivalence relation on the permutations by saying two permutations are equivalent provided they contain exactly the same elements. From the equivalence relation we get a partition of our set of permutations into equivalence classes. The combinations we want to count are precisely the equivalence classes. Since each equivalence class has the same size, we can find the number of classes by dividing the number of permutations by the size of each class.

This sort of quotient principle is also useful for solving questions where the answer isn't obviously either a permutation or combination.

Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.

Practice (5)

Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.

  1. True or false: The number of sequences of two distinct digits from 0-9 is twice the number of sets of two distinct digits from 0-9. Briefly explain.

  2. True or false: The number of sequences of three distinct digits from 0-9 is 3 times the number of sets of three distinct digits from 0-9. Briefly explain.

  3. What questions do you have after reading this section? Write at least one question about the content of this section that you are curious about.

  4. How many triangles are there with vertices from the points shown below? Note that we are not allowing degenerate triangles ones with all three vertices on the same line but we do allow non-right triangles. Explain why your answer is correct.

    Otkrij odgovor

    Hint:

    If you pick any three points, you can get a triangle, unless those three points are all on the \(x\)-axis or on the \(y\)-axis. There are other ways to start this as well, and any correct method should give the same answer.

    120.

  5. We have seen that the formula for \(P(n,k)\) is \(\dfrac{n!}{(n-k)!}\). Your task here is to explain why this is the right formula.

    1. Suppose you have 12 chips, each a different color. How many different stacks of 5 chips can you make? Explain your answer and why it is the same as using the formula for \(P(12,5)\).

    2. Using the scenario of the 12 chips again, what does \(12!\) count? What does \(7!\) count? Explain.

    3. Explain why it makes sense to divide \(12!\) by \(7!\) when computing \(P(12,5)\) (in terms of the chips).

    4. Does your explanation work for numbers other than 12 and 5? Explain the formula \(P(n,k) = \frac{n!}{(n-k)!}\) using the variables \(n\) and \(k\).

Symbols used here

\binom{n}{k}
binomial coefficient, "n choose k"
Number of k-element subsets of n things: n!/(k!(n−k)!).
n!
factorial
n × (n−1) × … × 1; the number of orderings of n things. 0! = 1.
P(A),\ P(A \mid B)
probability, conditional probability
Chance of A; chance of A given that B happened.
\sum_{k=1}^{n} a_k
summation
Add a_k for k = 1 up to n.
\prod_{k=1}^{n} a_k
product
Multiply a_k for k = 1 up to n.
\emptyset,\ |A|
empty set, cardinality
The set with no elements; the number of elements of A.

How to: Combinations and Permutations

  1. Correctly decide between using a combination or a permutation when solving a counting problem.
  2. Apply the correct combination or permutation to solve a counting problem.
  3. Explain the relationship between combinations and permutations and why their formulas are correct.

Questions people ask

Permutation or combination?

Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).

What is a graph in this sense?

Dots (vertices) joined by lines (edges) — not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.

Pokušaj i ti

Parts of this page are adapted from Levin, Discrete Mathematics: An Open Introduction (CC BY-SA 4.0). Condensed and re-explained here; errors are ours.

Više u Combinatorics & Graph Theory