Presentation is loading. Please wait.

Presentation is loading. Please wait.

Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n.

Similar presentations


Presentation on theme: "Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n."— Presentation transcript:

1 Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n element = n-permutation on this set Example: S={J,K,Q}: (K,Q,J) is a permutation of S; (J,K) is a 2-permutation of S Note: Set is unordered, but permutation is ordered!, e.g. (K,Q)≠(Q,K) The number of r-permutations of n objects is: P(n,r) =n(n-1)(n-2)...(n-r+1) =n! / (n-r)! 0<=r<=n And the number of permutations of n objects is P(n,n)=n! (Proof:1 st object can be chosen in n ways, 2 nd in (n-1) ways, and so on (k th in n-k+1 ways) until the r th object is chosen in n-r+1 ways. Now, use the product rule to get the formula given for P(n,r).) Reminder: n! = n(n-1)(n-2)...1. “n factorial.” (n+1)! = (n+1)n! 0! = 1

2 Permutation Examples Q: A mailman needs to bring 8 packages to 8 cities. How many ways are there to visit the cities? A: Pick first city among 8, second city among 7, etc. Each route is a permutation of 8-element set: Answer = P(8)=8! Q: How many permutations of the letters “abcdefgh” contain “abc” as a block. A: Rename “abc” to B. Question becomes: Count permutations of blocks Bdefgh: A: It’s the # permutations in a 6-element set, i.e. P(6) = 6! Q: How many ways to pick three prizes (gold,silver,bronze) among 100 contestants? A: It’s the number of 3-permutations in a 100-element set: P(100,3) = 100! / (100-3)! = 100! / 97! = 100*99*98

3 Combinations r-combination (AKA “unordered r-selection”) An unordered selection of r elements, i.e. a subset of size r of a set of n elements. Example: S={A,J,Q,K}. {A,J,K}={K,A,J}={J,K,A} are all 3-combinations of set S. The total number of r-combinations of a set of size n is denoted C(n,r), and given by: C(n,r) = n! / (r! (n-r)!), for 0<=r<=n Two facts to observe: 1. C(n,r) = C(n,n-r) Why does this make sense? 2. C(n,r) = P(n,r) / r! Why? Each of the C(n,r) subsets of r objects can be ordered in r! ways, meaning that C(n,r) * r! = P(n,r)

4 Computing Combinations Computing C(n,r) as n! / [(n-r)!r!] is grossly inefficient and, as a practical matter, can lead to incorrect results (even using computers!). Choose to compute C(n,r) if r ≤ n/2 “and/or” C(n,n-r) if r >n/2. Then, assuming wlog we have the first case, compute C(n,r) as: n (n-1)(n-2)(n-3)(n-4) … (n-r+2)(n-r+1) r (r-1)(r-2) (r-3) (r-4) … (2) (1) Simplify as much as you can. The result is always an integer. !

5 Examples: Consider a department with n=20 people. Q: How many 3-member committees possible? A: C(20,3) = 20! / 17!*3! = 20*19*18 / 1*2*3 Q: How many 3-member ordered committees possible? A: P(20,3) = C(20,3) * 3! = 20*19*18 Q: How many 3-letter words in an 20-letter alphabet? A: 20 3 = 20*20*20[repetitions allowed] Q: How many committees possible if you need 3 from math (n math =20) and 2 from computer science (n cs =30)? A: C(20,3) x C(30,2) Why the individual factors? Why the multiplication?

6 Examples: Q: How many bit-strings of size 10 contain exactly four 1’s? A: We need to place four 1’s in 10 slots: C(10,4). Q: How many decimal-strings of size 10 contain exactly four 1’s? A: C(10,4) x 9 6 Q: How many 10-digit strings have four 1’s and no other repeats? A: C(10,4) x P(9,6) = C(10,4) x 9*8*7*6*5*4 Q: How many 10-digit strings have (exactly) four 1’s and three 2’s? A: C(10,4) x C(6,3) x 8 3 = C(10,7) x C(7,4) x 8 3

7 Counting Like 2 n, C(n,r) and P(n,r), n! etc. grow very fast with n. C(12,r) P(12,r) r  rr Behavior of C(n,r) and P(n,r) for fixed n=12 and growing r.

8 Binomial Coefficients Q: What is the coefficient of x 12 y 13 in the expansion of (x+y) 25 ? A: We need to pick 12 x’s from 25 terms: C(25,12) = C(25,13). What is the coefficient of x 12 y 13 in (2x-3y) 25 ? First replace a=2x and b=-3y. The coefficient of a 12 b 13 in (a+b) 25 is C(25,12). Since C(25,12) a 12 b 13 = C(25,12) 2 12 x 12 (-3) 13 y 13 the coefficient we want must be C(25,12) 2 12 ∙(-3) 13 Notation:

9 Binomial Theorem How does this relate to |P(S)| = |2 S | = 2 |S| ? Some consequences:

10 Pascal’s Identity aS T j C(n, j) = C(n-1, j-1) + C(n-1, j) aS T j-1 =+ C(n,j) = C(n-1,j-1) + C(n-1,j) if 1 ≤ j ≤ n-1 [Note that C(n,n)=C(n,0)=1 for all n] aS T j You can select j objects from n in one of the following ways: 1.Take the first object and select j-1 from the last n-1 objects OR 2. Omit the first object and select j from the last n-1 objects.

11 Pascal’s Triangle C(5,2)=C(4,1)+C(4,2) C(0,0) C(1,0), C(1,1) C(2,0), C(2,1), C(2,2) C(3,0), C(3,1), C(3,2), C(3,3) C(4,0),C(4,1),C(4,2),C(4,3),C(4,4) C(5,0),C(5,1),C(5,2),C(5,3),C(5,4),C(5,5)

12 VanderMonde’s identity Proof: Let S m be a set with m elements; S n, a set with n different elements. Both sides of the equation equal |{A  S m  S n | |A|=r }|, the number of subsets of S m  S n which have r elements. remove r m n C(m+n,r) = C(m,j)C(n,r-j) 0 ≤ r ≤ m,n m n 0 r 1 r-1 2 r-2 = + + + … C(2n,n) = C(n,j) 2 0 ≤ j ≤ n Special case, m=n, using the fact that C(n,n-j)=C(n,j):

13 Another fact: C(n+1,r+1) = C(j,r) Example: C(6,4) = C(5+1,3+1) = C(3,3) + C(4,3) + C(5,3) [r=3,n=5] Proof: Follows from Pascal’s identity: C(n+1,r+1)= C(n,r) + C(n,r+1) = C(n,r) + ( C(n-1,r) + C(n-1,r+1) ) = C(n,r) + C(n-1,r) + ( C(n-2,r) + C(n-2,r+1) ) = C(n,r) + C(n-1,r) + C(n-2,r) + ( C(n-3,r) + C(n-3,r+1) ) … = C(n,r) + C(n-1,r) + C(n-2,r) + C(n-3,r) + … + C(r,r)

14 Selecting r items from n objects/classes If Order matters: When items not replaced (r-permutation): P(n,r) = n!/(n-r)! When items are replaced: n r If Order does not matter: When items not replaced (r-combination): C(n,r) C(n,r) = n!/(n-r)!r! = P(n,r)/r! When items are replaced: C(n+r-1,r) C(n+r-1,r) = C(n+r-1,n-1) = (n+r-1)!/(n-1)!r! Proof: Each such selection can be arranged so that all repetitions of the first (class of) object are followed by all repetions of the second (class of) object, followed by …, with n-1 barriers separating the non-identical (classes of) objects. Thus, we have r+n-1 slots each containing a barrier or an object. (What type of object is determined by how many barriers come before it.) We simply count the number of ways the n-1 barriers can be selected.

15 Permutations of Indistinguishable Objects Thrm: n objects s.t.: n 1 indistinguishable of type 1, n 2 indistinguishable of type 2, …, n k indistinguishable of type k. Number of different permutations of these n objects: n!/(n 1 ! n 2 ! … n k !) Proof: Correct for duplication in n! or compute that this value is the same as C(n,n 1 )C(n-n 1,n 2 )C(n-n 1 -n 2,n 3 )…C(n-n 1 -n 2 -…- n k-1,n k ) n!/(n 1 ! n 2 ! … n k !) is also the number of ways to distribute n distinguishable objects into k distinguishable containers where each container i gets n i objects. Proof: We are simply permuting the (indistinguishable) box assignments (n 1 to box 1, n 2 to box 2, …, n k to box k) among the n distinguishable objects.

16 Counting Examples, 1 Q: How many ways are there to select 5 bills from a cash box containing $1, $2, $5, $10, $20, $50, and $100 bills, assuming that there are at least 5 bills of each type and that the order of selection doesn’t matter? A: Unordered selection with replacement: C(5+7-1,7-1) = _______ Q: A cookie shop has 4 kinds of cookies. They are sold 6 to a bag. How many kinds of bags are there? A: Unordered selection with replacement: C(6+4-1,4-1) = _______

17 Counting Examples, 2 Q: How many integer solutions to x+y+z=11 with 0≤x,y,z? A: Make 11 selections with replacement from among 3 boxes (x,y,z). (Or simply look again at the proof of the formula for unordered selection with replacement.) C(11+3-1,3-1) = _______ Q: How many integer solutions to x+y+z=11 with 0<x,y,z ? A: This is the same as having 0≤x-1,y-1,z-1 saitisfying (x-1)+(y-1)+(z-1)=11-3=8. C(8+3-1,3-1) = _______ Q: How many integer solutions to x+y+z ≤11 with 0≤x,y,z ? A: This is the same as asking how many integer solutions to x+y+z+w=11 with 0≤x,y,z,w? C(11+4-1,4-1) = _______

18 Counting Examples, 3 Q: Distribute 10 (identical) candy bars among 8 friends? A: Unordered selection with replacement: C(10+8-1,8-1) _______ Q: How many different “words” can we create by reordering “SUCCESS”? A: 7 letters, including 3 S’s and 2 C’s with the rest unique: 7!/(3!∙2!) Q: How many 5 card hands can one get from a deck of 52 cards? A: C(52,5) = _______ Now suppose you need to deal 3 such hands for 3 different players. Q: How many ways can this be done if it matters who gets what hand? A: 52!/(5!∙5!∙5!∙37!) Q: How many ways if it doesn’t matter who gets what hand? A: 52!/(3!∙5!∙5!∙5!∙37!)

19 Counting Examples, 4 A math teacher has 40 different issues of a journal to pack into 4 boxes, 10 issues each. Q: How many ways can this be done if the boxes are numbered? A: 40!/(10!) 4 Q: How many ways can this be done if the boxes are not numbered? A: 40!/(4!∙(10!) 4 ) Q: How many ways can one put n books on k shelves assuming each shelf can hold at least n books? A: Put them in order (n! ways) and then decide where the k-1 shelf-breaks go (C(n+k-1,k-1) ways). n!∙C(n+k-1,k-1) = (n+k-1)!/(k-1)!


Download ppt "Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n."

Similar presentations


Ads by Google