CS 171 Lecture Outline Permutations of Multisets
Total Page:16
File Type:pdf, Size:1020Kb
CS 171 Lecture Outline February 03, 2010 Permutations of Multisets. Let S be a multiset that consists of n objects of which n1 are of type 1 and indistinguishable from each other. n2 are of type 2 and indistinguishable from each other. nk are of type k and indistinguishable from each other. and suppose n1 + n2 + . + nk = n. What is the number of distinct permutations of the n objects in S? A permutation of S can be constructed by the following k-step process: Step 1. Choose n1 places out of n places for type 1 objects. Step 2. Choose n2 places out of the remaining n − n1 places for type 2 objects. ...... Step k. Choose nk places of the remaining unused places for type k objects. By the multiplication rule, the total number of permutations of n objects in S is n n − n1 n − n1 − n2 −···− nk−1 · · · n1 n2 nk n! (n − n1)! n − n1 − n2 −···− nk−1 = · · · · n1!(n − n1)! n2!(n − n1 − n2)! nk!(n − n1 −···− nk)! n! = n1!n2! · · · nk! Example 1. How many permutations are there of the word MISSISSIPPI? Solution. We want to find the number of permutations of the multiset {1 · M, 4 · I, 4 · S, 2 · P }. Thus, n = 11,n1 = 1,n2 = 4,n3 = 4,n4 = 2. Then number of permutations is given by n! 11! = n1!n2!n3!n4! 1!4!4!2! Example 2. Consider n distinct objects and k bins labeled B1,B2,...,Bk. How many ways are there to distribute the objects in the bins so that bin Bi receives ni objects and k i=1 ni = n? P 2 Lecture Outline February 03, 2010 Solution. A partition of n objects into k labeled bins, B1,B2,...,Bk such that bin Bi gets ni objects can be constructed in k steps. Step i, 1 ≤ i ≤ k chooses ni objects that go in n−n1−n2−···−ni−1 i box B from the remaining objects. Step i, 1 ≤ i ≤ k can be performed in ni ways. By the multiplication rule, the total number of ways to achieve the required partition equals n n − n1 n − n1 − n2 n − n1 − n2 −···− nk−1 · · · n1 n2 n3 nk n! = n1!n2! · · · nk! Another way of arriving at the solution is as follows. Let the distinct objects be num- bered 1, 2,...,n. Consider the multiset A = {n1 · B1,n2 · B2,...,nk · Bk}. The procedure of obtaining the required partition can be done in k + 1 steps as follows. In Step 0, we obtain a permutation P of the multiset A. In step i, 1 ≤ i ≤ k, bin Bi gets the objects corresponding to the positions of ’Bi’ in P . n! Step 1 can be done in n1!n2!···nk! ways. There is exactly one way to do each of the remaining steps. Hence, by the multiplication rule, the required answer is n! n1!n2! · · · nk! Example 3. In how many ways can eight distinct books be divided among three students if Bill gets four books and Sharon and Marian each get two books? Solution. Such partition can be obtained in three steps. Step 1. Choose 4 books for Bill out of the available 8 books. Step 2. Choose 2 books for Sharon out of the remaining 4 books. Step 3. Choose 2 books for Marian out of the remaining 2 books. 8 4 Step 1 can be performed in 4 ways. Step 2 can be performed in 2 ways. Step 3 can be 2 performed in 2 = 1 way. By the multiplication rule, the total number of possible divisions is given by 8 4 8! 4! = × = 420. 42 4!4! 2!2! r-Combinations with Repetition Allowed. n We have seen that there are r ways of choosing r distinct elements from a set of n distinct elements. What if we allow elements to be repeated? In other words, we want to find the number of ways there are to choose a multiset of r elements from a multiset of n distinct elements with infinite copies of each of the n elements available? The following method was suggested in class. February 03, 2010 Lecture Outline 3 A multiset of r elements can be constructed in r steps as follows. In Step i, choose one of the n elements. Since each step can be done in n ways, there are nr multisets of r elements. Is this correct? No, this is not correct. For example, let S = {a, b}. Suppose we want to find the number of 2-combinations of S with repetition allowed. Note that the above procedure would consider the sets {a, b} and {b, a} as different whereas they are the same multiset and should not be counted twice. Using the above solution we get the answer as 4, but the correct answer is 3. In other words, the above procedure gives incorrect answer as it pays attention to the order of the r elements. We give the correct solution below. Think of the n elements of the set as categories. Then each multiset of size r can be represented as a string of n − 1 vertical bars (to separate the n categories) and r crosses (to represent the r elements to be chosen). The number of crosses in each category represents the number of times the element represented by that category is repeated. The number of strings of n − 1 vertical bars and r crosses is the number of ways to choose r positions from the available r + n − 1 positions. The r positions chosen will contain the crosses and the remaining positions will have the vertical bars. Thus the total number of possible ways to r+n−1 choose multisets of size r from n elements is r . Example 4. Consider 3 books: a computer science book, a math book, and a history book. Suppose the library has at least 6 copies of each of these books. How many ways are there to select 6 books? 6+3−1 8! Solution. The no of ways is 6 = 6!2! = 28. .