The permutation and combination of multiple sets

Transfer from: Click to open the link

First, let’s review the definition of permutation and combination without repeating elements


Arrangement , English called Permutation, it refers to remove an element from a specified number of elements in the set are sorted

Combination , the English name is Combination, which means that only a specified number of elements are taken from a set of elements, regardless of ordering


Arrangements for randomly taking r elements from a set of n different elements are: P(n, r) = n*(n-1)*...*(n-r+1) = n! / (nr )!, especially P(n,n) = n!

The combination of r elements from a set of n different elements is: C(n, r) = P(n, r) / r! = n! / ((nr)! * r!), especially C(n,n) = 1


Second, let's define the permutation and combination of multiple sets (multiset)


Let the multiple set S = {n1 * a1, n2 * a2, ..., nk * ak }, n = n1 + n2 + ... + nk

That is, the set S contains n1 elements a1, n2 elements a2,..., nk elements ak, ni is called the multiplicity of element ai, and k becomes the number of categories of the multiple set

The arrangement of any r elements in S is called the r arrangement of S. When r = n, there is the formula P(n; n1*a1, n2*a2, ..., nk*ak) = n! / ( n1! * n2! * ... * nk!)

The combination of any r elements in S is called the r combination of S. When r<=any ni, there is the formula  C(n; n1*a1, n2*a2, ..., nk*ak) =  C( k+r-1, r),

It can be seen from the formula that the combination of multiple sets is only related to the number of categories k  and the selected element r  , and has nothing to do with the total!


How to transform the problem description into a permutation and combination of multiple set problems?


Third, let’s look at some examples of multiple set problems


Example 1: How many sets of non-negative integer solutions are there in the linear equation x1 + x2 + ... + xk = r?

Solution: The non-negative integer solution of the above indeterminate equation corresponds to the following arrangement

1...101...1 01...1 0 ...... 01...1

x1 pcs x2 pcs x3 pcs ...... xk pcs

Among them, k-1 0s divide r 1s into k segments, and the number of 1s in each segment is x1, x2, ..., xk, 

Obviously this arrangement is a full arrangement of multiple sets S = {r * 1, (k-1) * 0}

That is: P(r+k-1; r*1, (k-1)*0) = (r+k-1)! / (r! * (k-1)!) = C( r+k- 1, r), that is , select r types from k types of elements


Example 2: A station has 6 entrances, and each entrance can only enter one person at a time. What is the plan for a group of 9 people to enter the station?

Answer: The inbound plan can be expressed as 

1 011 011 01 011 01 

g1 g2 g3 g4 g5 g6

Among them, 1 means different people, and 0 means door frame, 6-1= 5 door frames divide the sequence into six segments,

Then any inbound plan can be expressed as an arrangement of the above 14 elements S = {5 * 1, 1 * p1, 1 * p2, ..., 1 * p9}

That is: P(5+9; 5*1, 1*p1, 1*p2, ..., 1*p9 ) = 14! / (5! * 1! * .... 1!) = 14! / 5!


Example 3: Find the number of non-descending paths from (0,0) to (m,n)

Answer: No matter which path, you must take m steps in the x direction and n steps in the y direction, and establish a one-to-one correspondence between the number of non-descending paths and the arrangement of multiple sets S = {m * x, n * y }. So the total number of grids is P(m+n; m*x, n*y) = (m+n)! / (m! * n!) = C(m+n, n) = C(m+n, m)


Generally, if c>=a, d>=b, the number of non-decreasing paths from (a,b) to (c,d) is C(c-a+db, ca)


Expansion problem: Based on the above example, if m<n, find the non-declining path data from point (0,1) to point (m,n) without touching the diagonal y=x (contact includes passing through)

解答:从(0,1)到(m,n)的非降路径,有的接触 y=x,有的不接触,对于每条接触 y=x的非降路径,做(0,1)关于y=x的对称点(1,0)到(m,n)的对称非降路径,容易看出从(0,1)到(m,n)接触y=x的非降路径与 (1,0)到(m,n)的非降路径(必穿过y=x)一一对应,

故所求的非降路径数为 C(m+n-1, m) - C(m+n-1, m-1)


例四、将r个相同的小球放入n个不同的盒子,总共有多少种方案?

解答:该问题可以转化为r个相同的小球与n-1个相同的盒壁的排列问题

1...1 0 1...1 0 1...1 0 ...... 0 1...1

其中有 n-1个 0 分成 n段,每段表示不同的盒子, 每段中1的个数表示该盒子里放入的小球总数,总共r个1

即:P( r+n-1; r*1, (n-1)*0 ) = (r+n-1)! / ( r! * (n-1)! ) = C( r+n-1, r)


例五、求集合 X = { 1,2,..., n }的不含相邻整数的k元子集个数

解答:任意一个X的k元子集s都可以对应于一个由0,1组成的有序n重组(a1 a2 ... an),其中 ai = 1 当 i属于s,否则 ai = 0,当i不属于s,由于s中不含相邻整数,所以在此n重组中没有两个1是相邻的,所以子集s是与这样的n重组 S = { k*1, (n-k)*0 }之间是一一对应的,由于任意两个1彼此不相邻,故可以把(n-k)个0依次排列,然后在(n-k+1)个空隙中插入k个1,所以从(n-k+1)个空隙中选择k个位置来放置1,有 C(n-k+1, k) 种选法,这也是原问题所对应的答案。


其他例子.......To Be Continue


Guess you like

Origin blog.csdn.net/qq_36909245/article/details/80456694