← 学习库 Discrete Mathematics (Levin) · 中英对照 目录

1.3 Combinations and Permutations 组合与排列

本页译自 LibreTexts · Discrete Mathematics (Levin) 第 1.3 章。公式经 MathJax 渲染,自定义宏已注入。

Investigate! 探究!

You have a bunch of chips which come in five different colors: red, blue, green, purple and yellow.

你有一堆筹码,共有五种不同颜色:红、蓝、绿、紫、黄。
  1. How many different two-chip stacks can you make if the bottom chip must be red or blue? Explain your answer using both the additive and multiplicative principles.
  2. How many different three-chip stacks can you make if the bottom chip must be red or blue and the top chip must be green, purple or yellow? How does this problem relate to the previous one?
  3. How many different three-chip stacks are there in which no color is repeated? What about four-chip stacks?
  4. Suppose you wanted to take three different colored chips and put them in your pocket. How many different choices do you have? What if you wanted four different colored chips? How do these problems relate to the previous one?
  1. 若底层的筹码必须是红色或蓝色,你能堆出多少种不同的两枚筹码堆?请用加法原理和乘法原理解释你的答案。
  2. 若底层筹码必须是红色或蓝色、顶层筹码必须是绿色、紫色或黄色,你能堆出多少种不同的三枚筹码堆?这道题与前一道有何关联?
  3. 有多少种三枚筹码堆不出现重复颜色?四枚筹码堆呢?
  4. 假设你想取三种不同颜色的筹码放进衣袋,共有多少种不同的取法?若想取四种不同颜色呢?这些题与前一道有何关联?

A permutation is a (possible) rearrangement of objects. For example, there are 6 permutations of the letters a, b, c:

排列(permutation)是对物体(可能)重排的结果。例如,字母 a, b, c 共有 6 种排列:

$\begin{equation*} abc, acb, bac, bca, cab, cba. \end{equation*}$

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\text{.}$

我们知道上面已经列出了全部排列——第一个位置有 3 种选择,接着第二个位置有 2 种选择,最后一个位置只剩 1 种选择。根据乘法原理,我们将它们相乘:$3\cdot 2 \cdot 1\text{。}$

Example 1

示例 1

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

a, b, c, d, e, f 这六个字母共有多少种排列?

Answer

解答

We do NOT want to try to list all of these out. 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 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.

我们并不想把这些排列全部列出来。不过,若真要列,得先选一个字母写在第一位。这个字母有 6 种选择。选定首字母后,第二位有 5 种选择(不能重复首字母;我们是在重排字母,每种只有一个),再往后第三位有 4 种、第四位有 3 种、第五位有 2 种,最后一位只剩 1 种。因此这 6 个字母的排列共有 $6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1 = 720$ 种。

A piece of notation is helpful here: $n!\text{,}$ 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 permutation of 6 letters, as seen in the previous example is $6! = 6\cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1\text{.}$ This generalizes:

这里引入一个记号会很有帮助:$n!\text{(}$读作「$n$ 的阶乘」)是所有小于或等于 $n$ 的正整数的乘积(为方便起见,我们额外规定 $0! = 1$)。因此,如前例所见,6 个字母的排列数为 $6! = 6\cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1\text{。}$ 这一结论可以推广:

Permutations of $n$ Elements $n$ 个元素的排列

There are $n! = n\cdot (n-1)\cdot (n-2)\cdot \cdots \cdot 2\cdot 1$ permutations of $n$ (distinct) elements.

$n$ 个(互异)元素的排列数为 $n! = n\cdot (n-1)\cdot (n-2)\cdot \cdots \cdot 2\cdot 1\text{。}$

Counting Bijective Functions 双射函数的计数

How many functions $f:\{1,2,\ldots,8\} \to \{1,2,\ldots, 8\}$ are bijective?

有多少个函数 $f:\{1,2,\ldots,8\} \to \{1,2,\ldots, 8\}$ 是双射

Solution

解答

Remember what it means for a function to be bijective: each element in the codomain must be the image of exactly one element of the domain. Using two-line notation, we could write one of these bijections as

回想双射的含义:上域中每个元素都恰好是定义域中某一个元素的像。用双行记号,我们可以把其中一个双射写成

$\begin{equation*} f = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ 3 & 1 & 5 & 8 & 7 & 6 & 2 & 4 \end{pmatrix} \end{equation*}$

What we are really doing is just rearranging the elements of the codomain, so we are creating a permutation of 8 elements. In fact, "permutation" is another term used to describe bijective functions from a finite set to itself.

我们真正在做的事,只不过是把上域中的元素重新排列,于是就得到了一个 8 个元素的排列。事实上,「排列」这个词也用来指从一个有限集到自身的双射函数。

If you believe this, then you see the answer must be $8! = 8 \cdot 7 \cdot\cdots\cdot 1 = 40320\text{.}$ You can see this directly as well: for each element of the domain, we must pick a distinct element of the codomain to map to. There are 8 choices for where to send 1, then 7 choices for where to send 2, and so on. We multiply using the multiplicative principle.

若你接受这一点,便会看出答案必为 $8! = 8 \cdot 7 \cdot\cdots\cdot 1 = 40320\text{。}$ 你也可以直接看出:对定义域中每个元素,我们必须为它指定上域中一个互异的元素作为像。1 的像有 8 种选法,2 的像有 7 种,依此类推。我们再用乘法原理相乘即可。

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

有时我们并不想重排所给的全部字母 / 数字 / 元素。

Example 3

示例 3

How many 4 letter "words" can you make from the letters a through f, with no repeated letters?

用字母 af 能组成多少个无重复字母的四字母「单词」?

Solution

解答

This is just like the problem of permuting 4 letters, only now we have more choices for each letter. For the first letter, there are 6 choices. For each of those, there are 5 choices for the second letter. Then there are 4 choices for the third letter, and 3 choices for the last letter. The total number of words is $6\cdot 5\cdot 4 \cdot 3 = 360\text{.}$ This is not $6!$ because we never multiplied by 2 and 1. We could start with $6!$ and then cancel the 2 and 1, and thus write $\frac{6!}{2!}\text{.}$

这与排列 4 个字母的问题类似,只不过现在每个字母都有更多选择。首字母有 6 种选法;在此基础上,第二个字母有 5 种;接着第三个字母有 4 种,最后一个字母有 3 种。单词总数为 $6\cdot 5\cdot 4 \cdot 3 = 360\text{。}$ 这不等于 $6!$,因为我们没有乘上 2 和 1。我们可以先从 $6!$ 出发,再约掉 2 和 1,从而写成 $\frac{6!}{2!}\text{。}$

In general, we can ask how many permutations exist of $k$ objects choosing those objects from a larger collection of $n$ objects. (In the example above, $k = 4\text{,}$ and $n = 6\text{.)}$ We write this number $P(n,k)$ and sometimes call it a $k$-permutation of $n$ elements. From the example above, we see that to compute $P(n,k)$ we must apply the multiplicative principle to $k$ numbers, starting with $n$ and counting backwards. For example

一般地,我们可以问:从含 $n$ 个对象的一个更大的集合中选出 $k$ 个对象,能排出多少种排列?(在上例中,$k = 4\text{,}$且 $n = 6\text{。)}$ 我们把这个数记作 $P(n,k)$,有时也称它为 $n$ 个元素的 $k$ 排列。由上例可见,要计算 $P(n,k)$,必须把乘法原理应用于 $k$ 个数,从 $n$ 开始倒数。例如

$\begin{equation*} P(10, 4) = 10\cdot 9 \cdot 8 \cdot 7. \end{equation*}$

Notice again that $P(10,4)$ starts out looking like $10!\text{,}$ but we stop after 7. We can formally account for this "stopping" by dividing away the part of the factorial we do not want:

再注意一点:$P(10,4)$ 开头看起来像 $10!\text{,}$但我们在 7 之后就停下了。我们可以用「除以不想要的阶乘部分」来严格解释这一「截断」:

$\begin{equation*} P(10,4) = \frac{10\cdot 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}{6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1} = \frac{10!}{6!}. \end{equation*}$

Careful: The factorial in the denominator is not $4!$ but rather $(10-4)!\text{.}$

注意:分母中的阶乘不是 $4!$,而是 $(10-4)!\text{。}$

$k$-Permutations of $n$ Elements $n$ 个元素的 $k$ 排列

$P(n,k)$ is the number of $k$-permutations of $n$ elements, the number of ways to arrange $k$ objects chosen from $n$ distinct objects.

$P(n,k)$ 是 $n$ 个元素的 $k$ 排列数,即从 $n$ 个互异对象中选出 $k$ 个并排列的方式数。

$\begin{equation*} P(n,k) = \frac{n!}{(n-k)!}. \end{equation*}$

Note that when $n = k\text{,}$ we have $P(n,n) = \frac{n!}{(n-n)!} = n!$ (since we defined $0!$ to be 1). This makes sense — we already know $n!$ gives the number of permutations of all $n$ objects.

注意,当 $n = k$ 时,$P(n,n) = \frac{n!}{(n-n)!} = n!$(因为我们规定 $0! = 1$)。这是合理的——我们已经知道 $n!$ 给出全部 $n$ 个对象的排列数。

Counting Injective Functions 单射函数的计数

How many functions $f:\{1,2,3\} \to \{1,2,3,4,5,6,7,8\}$ are injective?

有多少个函数 $f:\{1,2,3\} \to \{1,2,3,4,5,6,7,8\}$ 是单射

Solution

解答

Note that it doesn't make sense to ask for the number of bijections here, as there are none (because the codomain is larger than the domain, there are no surjections). But for a function to be injective, we just can't use an element of the codomain more than once.

注意,此处问「双射」的个数没有意义,因为根本不存在双射(上域比定义域大,故也没有满射)。但要使一个函数为单射,只需不重复使用上域中的元素即可。

We need to pick an element from the codomain to be the image of 1. There are 8 choices. Then we need to pick one of the remaining 7 elements to be the image of 2. Finally, one of the remaining 6 elements must be the image of 3. So the total number of functions is $8\cdot 7 \cdot 6 = P(8,3)\text{.}$

我们要从上域中选一个元素作为 1 的像,有 8 种选法;再从上域剩下的 7 个元素中选一个作为 2 的像;最后,剩下的 6 个元素之一必须作为 3 的像。因此函数总数为 $8\cdot 7 \cdot 6 = P(8,3)\text{。}$

What this demonstrates in general is that the number of injections $f:A \to B\text{,}$ where $\|A\| = k$ and $\|B\| = n\text{,}$ is $P(n,k)\text{.}$

一般地,这说明了:单射 $f:A \to B$(其中 $\|A\| = k$、$\|B\| = n$)的个数为 $P(n,k)\text{。}$

Here is another way to find 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 $k$ objects, we know there are $k!$ ways to arrange (permute) them. But how do you select $k$ objects from the $n\text{?}$ You have $n$ objects, and you need to choose $k$ of them. You can do that in $\binom{n}{k}$ ways. Then for each choice of those $k$ elements, we can permute them in $k!$ ways. Using the multiplicative principle, we get another formula for $P(n,k)\text{:}$

下面给出另一种求 $n$ 个元素的 $k$ 排列数的方法:先选出将进入排列的 $k$ 个元素,再数出排列它们的方式数。一旦选定了这 $k$ 个对象,我们知道有 $k!$ 种方式去排列(重排)它们。但怎样从 $n$ 个对象中选取 $k$ 个呢?你有 $n$ 个对象,需要选取其中的 $k$ 个,这有 $\binom{n}{k}$ 种方式。而对每一种这样的 $k$ 元选取,我们又能以 $k!$ 种方式排列它们。运用乘法原理,便得到 $P(n,k)$ 的另一个公式:

$\begin{equation*} P(n,k) = \binom{n}{k}\cdot k!. \end{equation*}$

Now since we have a closed formula for $P(n,k)$ already, we can substitute that in:

既然我们已经有了 $P(n,k)$ 的闭式,便可代入其中:

$\begin{equation*} \frac{n!}{(n-k)!} = \binom{n}{k} \cdot k!. \end{equation*}$

If we divide both sides by $k!$ we get a closed formula for $\binom{n}{k}\text{.}$

若两边同除以 $k!$,便得到 $\binom{n}{k}$ 的闭式:

Closed Formula for $\binom{n}{k}$ $\binom{n}{k}$ 的闭式

$\begin{equation*} \binom{n}{k} = \frac{n!}{(n-k)!k!} \end{equation*}$

We say $P(n,k)$ counts permutations, and $\binom{n}{k}$ counts combinations. The formulas for each are very similar, there is just an extra $k!$ in the denominator of $\binom{n}{k}\text{.}$ That extra $k!$ accounts for the fact that $\binom{n}{k}$ does not distinguish between the different orders that the $k$ objects can appear in. We are just selecting (or choosing) the $k$ objects, not arranging them. Perhaps "combination" is a misleading label. We don't mean it like a combination lock (where the order would definitely matter). Perhaps a better metaphor is a combination of flavors — you just need to decide which flavors to combine, not the order in which to combine them.

我们说 $P(n,k)$ 计的是排列,$\binom{n}{k}$ 计的是组合。二者的公式非常相似,只是 $\binom{n}{k}$ 的分母上多了一个 $k!\text{。}$ 这多出来的 $k!$ 正说明了:$\binom{n}{k}$ 不区分这 $k$ 个对象出现的不同顺序——我们只是把 $k$ 个对象出来,而不对它们排序。或许「组合」这个叫法有些误导:它不像密码锁那样(顺序肯定重要)。或许更好的类比是风味的搭配——你只需决定搭配哪些风味,而不必关心搭配的先后顺序。

To further illustrate the connection between combinations and permutations, we close with an example.

为了进一步说明组合与排列之间的联系,我们以一道例题作结。

Example 5

示例 5

You decide to have a dinner party. Even though you are incredibly popular and have 14 different friends, you only have enough chairs to invite 6 of them.

你决定办一场晚宴。尽管你人缘极好、有 14 个不同的朋友,但你只有足够的椅子邀请其中 6 位。
  1. How many choices do you have for which 6 friends to invite?
  2. What if you need to decide not only which friends to invite but also where to seat them along your long table? How many choices do you have then?
  1. 邀请哪 6 位朋友,你共有多少种选择?
  2. 若你不仅要决定邀请哪些朋友,还要决定他们沿长桌的座位,那你又有多少种选择?

Solution

解答
  1. You must simply choose 6 friends from a group of 14. This can be done in $\binom{14}{6}$ ways. We can find this number either by using Pascal's triangle or the closed formula: $\frac{14!}{8!\cdot 6!} = 3003\text{.}$
  2. Here you must count all the ways you can permute 6 friends chosen from a group of 14. So the answer is $P(14, 6)\text{,}$ which can be calculated as $\frac{14!}{8!} = 2192190\text{.}$
  1. 你只需从 14 人中选出 6 位朋友,共有 $\binom{14}{6}$ 种选法。这个数既可用帕斯卡三角形求得,也可由闭式算出:$\frac{14!}{8!\cdot 6!} = 3003\text{。}$
  2. 这里你要数出从 14 人中选出的 6 位朋友的所有排列方式,因此答案为 $P(14, 6)\text{,}$可算得 $\frac{14!}{8!} = 2192190\text{。}$

Notice that we can think of this counting problem as a question about counting functions: how many injective functions are there from your set of 6 chairs to your set of 14 friends (the functions are injective because you can't have a single chair go to two of your friends).

注意,我们可以把这一计数问题看作一个关于函数计数的问题:从你那 6 把椅子的集合到你那 14 位朋友的集合,有多少个单射函数?(这些函数是单射,因为你不可能让一把椅子对应两位朋友。)

How are these numbers related? Notice that $P(14,6)$ is much larger than $\binom{14}{6}\text{.}$ This makes sense. $\binom{14}{6}$ picks 6 friends, but $P(14,6)$ arranges the 6 friends as well as picks them. In fact, we can say exactly how much larger $P(14,6)$ is. In both counting problems we choose 6 out of 14 friends. For the first one, we stop there, at 3003 ways. But for the second counting problem, each of those 3003 choices of 6 friends can be arranged in exactly $6!$ ways. So now we have $3003\cdot 6!$ choices and that is exactly $2192190\text{.}$

这两个数有何关联?注意 $P(14,6)$ 远大于 $\binom{14}{6}\text{。}$ 这是合理的:$\binom{14}{6}$ 只是选出 6 位朋友,而 $P(14,6)$ 既选人又排座。事实上,我们能精确说出 $P(14,6)$ 大多少。两个计数问题都是从 14 人中选 6 人:前者到此为止,共 3003 种;而后者对这 3003 种每一种 6 人选法,又都能以恰好 $6!$ 种方式安排座位。于是现在共有 $3003\cdot 6!$ 种选择,而它恰好等于 $2192190\text{。}$

Alternatively, look at the first problem another way. We want to select 6 out of 14 friends, but we do not care about the order they are selected in. To select 6 out of 14 friends, we might try this:

换个角度看第一道题。我们想从 14 人中选出 6 人,却不关心被选中的顺序。要选出 6 人,我们或许会这样试:

$\begin{equation*} 14 \cdot 13 \cdot 12 \cdot 11 \cdot 10 \cdot 9. \end{equation*}$

This is a reasonable guess, since we have 14 choices for the first guest, then 13 for the second, and so on. But the guess is wrong (in fact, that product is exactly $2192190 = P(14,6)$). It distinguishes between the different orders in which we could invite the guests. To correct for this, we could divide by the number of different arrangements of the 6 guests (so that all of these would count as just one outcome). There are precisely $6!$ ways to arrange 6 guests, so the correct answer to the first question is

这猜得有道理,因为第一位客人有 14 种选法,第二位有 13 种,依此类推。但这个猜测是错的(事实上,该乘积恰好是 $2192190 = P(14,6)$)。它区分了邀请客人的不同先后顺序。要修正这一点,我们可以除以 6 位客人的不同排列方式数(这样所有这些排列都只算作一个结果)。6 位客人恰好有 $6!$ 种排列方式,因此第一道题的正确答案是

$\begin{equation*} \frac{14 \cdot 13 \cdot 12 \cdot 11\cdot 10 \cdot 9}{6!}. \end{equation*}$

Note that another way to write this is

注意,这也可以写成

$\begin{equation*} \frac{14!}{8!\cdot 6!}. \end{equation*}$

which is what we had originally.

而这正是我们最初得到的式子。