Pemutations and Combinations Mach 11, 2005 1 Two Counting Pinciples Addition Pinciple Let S 1, S 2,, S m be subsets of a finite set S If S S 1 S 2 S m, then S S 1 + S 2 + + S m Multiplication Pinciple Let S 1, S 2,, S m be finite sets and S S 1 S 2 S m Then S S 1 S 2 S m Example 11 Detemine the numbe of positive integes which ae factos of the numbe 5 3 7 9 13 33 8 The numbe 33 can be factoed into 3 11 By the unique factoization theoem of positive integes, each facto of the given numbe is of the fom 3 i 5 j 7 k 11 l 13 m, whee 0 i 8, 0 j 3, 0 k 9, 0 l 8, and 0 m 1 Thus the numbe of factos is 9 4 10 9 2 7280 Example 12 How many two-digit numbes have distinct and nonzeo digits? A two-digit numbe ab can be egaded as an odeed pai (a, b whee a is the tens digit and b is the units digit The digits in the poblem ae equied to satisfy a 0, b 0, a b The digit a has 9 choices, and fo each fixed a the digit b has 8 choices So the answe is 9 8 72 The answe can be obtained in anothe way: Thee ae 90 two-digit numbes, ie, 10, 11, 12,, 99 Howeve, the 9 numbes 10, 20,, 90 should be excluded; anothe 9 numbes 11, 22,, 99 should be also excluded So the answe is 90 9 9 72 Example 13 How many odd numbes between 1000 and 9999 have distinct digits? A numbe a 1 a 2 a 3 a 4 between 1000 and 9999 can be viewed as an odeed tuple (a 1, a 2, a 3, a 4 Since a 1 a 2 a 3 a 4 1000 and a 1 a 2 a 3 a 4 is odd, then a 1 1, 2,, 9 and a 4 1, 3, 5, 7, 9 Since a 1, a 2, a 3, a 4 ae distinct, we conclude: a 4 has 5 choices; when a 4 is fixed, a 1 has 8( 9 1 choices; when a 1 and a 4 ae fixed, a 2 has 8( 10 2 choices; and when a 1, a 2, a 4 ae fixed, a 3 has 7( 10 3 choices Thus the answe is 8 8 7 5 2240 Example 14 In how many ways to make a basket of fuit fom 6 oanges, 7 apples, and 8 bananas so that the basket contains at least two apples and one banana? Let a 1, a 2, a 3 be the numbe of oanges, apples, and bananas in the basket espectively Then 0 a 1 6, 2 a 2 7, and 1 a 3 8, ie, a 1 has 7 choices, a 2 has 6 choices, and a 3 has 8 choices Thus the answe is 7 6 8 336 Geneal Ideas about Counting: Count the numbe of odeed aangements o odeed selections of objects 1
(a without epetition, (b with epetition allowed Count the numbe of unodeed aangements o unodeed selections of objects (a without epetition, (b with epetition allowed A multiset M is a collection whose membes need not be distinct Fo instance, the collection is a multiset; and sometimes it is convenient to wite M {a, a, b, b, c, d, d, d, 1, 2, 2, 2, 3, 3, 3, 3} M {2a, 2b, c, 3d, 1, 3 2, 4 3} A multiset M ove a set S can be viewed as a function v : S N fom S to the set N of nonnegative integes; each element x S is epeated v(x times in M; we wite M (S, v Example 15 How many integes between 0 and 10,000 have exactly one digit equal to 5? Fist Method: Let S be the set of all such numbes, and let S i be the set of such numbes having exactly i digits, 1 i 4 Clealy, S 1 1 Fo S 2, if the tens is 5, then the units has 9 choices; if the units is 5, then the tens has 8 choices; thus S 2 9 + 8 17 Fo S 3, if the tends is 5, then the units has 9 choices and the hundeds has 8 choices; if the hundeds is 5, then both tens and the units have 9 choices; if the units is 5, then the tens has 9 choices and hundeds has 8 choices; thus S 3 9 9 + 8 9 + 8 9 225 Fo S 4, if the thousands is 5, then each of the othe thee digits has 9 choices; if the hundeds o tens o units is 5, then the thousands has 8 choices, each of the othe two digits has 9 choices; thus S 4 9 9 9+3 8 9 9 2, 673 Theefoe S S 1 + S 2 + S 3 + S 4 1 + 17 + 225 + 2, 673 2, 916 Second Method: Let us wite any intege with less than 5 digits in a fomal 5-digit fom by adding zeos in the font Fo instance, we wite 35 as 00035, 836 as 00836 Let S i be the set of integes of S whose ith digit is 5, 1 i 4 Then S i 9 9 9 729 Thus S 4 729 2, 916 Example 16 How many distinct 5-digit numeals can be constucted out of the digits 1, 1, 1, 6, 8? The digit 6 can be located in any of the 5 positions; then 8 can be located in in 4 positions Thus the answe is 5 4 20 2 Pemutation of Sets Definition 21 An -pemutation of n objects is a linealy odeed selection of objects fom a set of n objects The numbe of -pemutations of n objects is denoted by P (n, An n-pemutation of n objects is just called a pemutation of n objects The numbe of pemutations of n objects is denoted by, ead n factoial Theoem 22 The numbe of -pemutations of an n-set equals P (n, n(n 1 (n + 1 Coollay 23 The numbe of pemutations of an n-set is (n! 2
Example 21 Find the numbe of ways to put the numbes 1, 2,, 8 into the squaes of 6-by-6 gid so that each squae contains at most one numbe Thee ae 36 squaes in the 6-by-6 gid We label the squaes by the numbes 1, 2,, 36 as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 5 3 7 4 6 2 8 1 The filling patten on the ight can be viewed as the 8-pemutation (35, 22, 7, 16, 3, 21, 11, 26 of {1, 2,, 36} Thus the answe is 36! P (36, 8 (36 36! 2 Example 22 What is the numbe of ways to aange the 26 alphabets so that no two of the vowels a, e, i, o, and u occu next to each othe? We fist have the 21 consonants aanged abitaily and thee ae 21! ways to do so Fo each such 21- pemutation, we aange the 5 vowels a, e, i, o, u in 22 positions between consonants; thee ae P (22, 5 ways of such aangement Thus the answe is 21! P (22, 5 21! 22! 17! Example 23 Find the numbe of 7-digit numbes in base 10 such that all digits ae nonzeo, distinct, and the digits 8 and 9 do not appea next to each othe Fist method: The numbes in question can be viewed as 7-pemutations of {1, 2,, 9} with cetain estictions Such pemutations can be divided into thee types: (i pemutations without 8 and 9; (ii pemutations with eithe 8 o 9 but not both; and (iii pemutations with both 8 and 9 (i Thee ae P (7, 7 7! 5, 040 such pemutations (ii Thee ae P (7, 6 6-pemutations of {1, 2,, 7} Thus thee ae 2 7 P (7, 6 2 7 7! 1! 70, 560 such pemutations (iii Fo each 5-pemutation of {1, 2,, 7}, thee ae 6 ways to inset 8 in it, and then thee ae 5 ways to inset 9 Thus thee ae 6 5 P (7, 5 75, 600 Theefoe the answe is 5, 040 + 70, 560 + 75, 600 151, 200 Second method: Let S be the set of 7-pemutations of {1, 2,, 9} Let A be the subset of 7-pemutations of S in the poblem Then Ā is the set of 7-pemutations of S such that 89 o 98 appeas somewhee We may think of 89 and 98 as a single object in whole, then Ā can be viewed as the set of 6-pemutations of {1, 2, 3, 4, 5, 6, 7, 89} and the 6-pemutations of {1, 2, 3, 4, 5, 6, 7, 98} Thus the answe is S P (9, 7 2P (8, 6 + 2P (7, 7 9! 2! 2 2! + 2 7! 151, 200 0! A cicula -pemutation of a set S is an odeed objects of S aanged as a cicle; thee is no the beginning object and the ending object Theoem 24 The numbe of cicula -pemutations of an n-set equals P (n, (n! 3
Poof Let S be an n-set Let X be the set of all -pemutations of S, and let Y be the set of all cicula - pemutations of S Define a function f : X Y as follows: Fo each -pemutation a 1 a 2 a of S, f(a 1 a 2 a is the cicula -pemutation such that a 1 a 2 a a 1 a 2 is counteclockwise on a cicle Clealy, f is sujective Moeove, thee ae exactly -pemutations sent to one cicula -pemutation In fact, the pemutations a 1 a 2 a 3 a 1 a, a 2 a 3 a 4 a a 1,, a a 1 a 2 a 2 a 1 ae sent to the same cicula -pemutation Thus the answe is Y X P (n, Coollay 25 The numbe of cicula pemutations of an n-set is equal to (n 1! Example 24 Twelve people, including two who do no wish to sit next to each othe, ae to be seated at a ound table How many cicula seating plans can be made? Fist method: We may have 11 people (including one of the two unhappy pesons but not both to sit fist; thee ae 10! such seating plans Next the second unhappy peson can sit anywhee except the left side and ight side of the fist unhappy peson; thee ae 9 choices fo the second unhappy peson Thus the answe is 9 10! Second method: Thee ae 11! seating plans fo the 12 people with no estiction We need to exclude those seating plans that the unhappy pesons a and b sit next to each othe Note that a and b can sit next to each othe in two ways: ab and ba We may view a and b as an insepaable twin; thee ae 2 10! such seating plans Thus the answe is given by 11! 2 10! 9 10! Example 25 How many diffeent pattens of necklaces with 18 beads can be made out of 25 available beads of the same size but in diffeent colos? Answe: P (25,18 18 2 25! 36 7! 3 Combinations of Sets A combination is a collection of objects (ode is immateial fom a given set An -combination of an n-set S is an -subset of S We denote by the numbe of -combinations of an n-set, ead n choose Theoem 31 The numbe of -combinations of an n-set equals!(n! P (n,! Fist Poof Let S be an n-set Let X be the set of all pemutations of S, and let Y be the set of all -subsets of S Conside a map f : X Y defined by f(x 1 x 2 x x +1 x n {x 1, x 2,, x }, x 1 x 2 x n X Clealy, f is sujective Moeove, fo any -subset A {x 1, x 2,, x } Y, thee ae! pemutations of A and (n! pemutations of the complement Ā Then Thus f 1 (A!(n! Theefoe f 1 (A {στ : σ is a pemutation of A and τ is a pemutation of Ā} Y X!(n!!(n! 4
Second Method: Let X be the set of all -pemutations of S and let Y be the set of all -subsets of S Conside a map f : X Y defined by f(x 1 x 2 x {x 1, x 2,, x }, x 1 x 2 x X Clealy, f is sujective Moeove, thee ae exactly! pemutations of {x 1, x 2,, x } sent to {x 1, x 2,, x } Thus Y X! P (n,! Example 31 How many 8-lette wods can be constucted fom 26 lettes of the alphabets if each wod contains 3, 4, o 5 vowels? It is undestood that thee is no estiction on the numbe of times a lette can be used in a wod The numbe of wods with 3 vowels: Thee ae ( 8 3 ways to choose 3 vowel positions in a wod; each vowel position can be filled with one of the 5 vowels; the consonant position can be any of 21 consonants Thus thee ae 5 3 21 5 wods having exactly 3 vowels ( 8 3 The numbe of wods with 4 vowels: ( 8 4 5 4 21 4 The numbe of wods with 5 vowels: ( 8 5 5 5 21 3 Thus the answe is ( 8 5 3 21 5 + 3 Coollay 32 Fo integes n, such that n 0, ( 8 5 4 21 4 + 4 ( n n ( 8 5 5 21 3 5 Theoem 33 The numbe of subsets of an n-set S equals + + + + 2 0 1 2 n n 4 Pemutations of Multisets Let M be a multiset An -pemutation of M is an odeed aangement of objects of M If M n, then an n-pemutation of M is called a pemutation of M Theoem 41 Let M be a multiset of k diffeent types whee each type has infinitely many elements Then the numbe of -pemutations of M equals k Example 41 What is the numbe of tenay numeals with at most 4 digits? The question is to find the numbe of 4-pemutations of the multiset { 0, 1, 2} Thus the answe is 3 4 81 Theoem 42 Let M be a multiset of k types with epetition numbes n 1, n 2,, n k espectively Let n n 1 + n 2 + + n k Then the numbe of pemutations of M equals Poof List the elements of M as n 1!n 2! n k! a,, a, b,, b,, d,, d }{{}}{{}}{{} n 1 n 2 n k Let S be the set consisting of the elements a 1, a 2,, a n1, b 1, b 2,, b n2,, d 1, d 2,, d nk Let X be the set of all pemutations of S, and let Y be the set of all pemutations of M Thee is a map f : X Y, sending each pemutation of S to a pemutation of M by emoving the subscipts of the elements Note that fo each pemutation 5
π of M thee ae n 1!, n 2!,, and n k! ways to put the subscipts of the fist, the second,, and the kth type elements back, espectively Thus thee ae n 1!n 2! n k! elements of X sent to π by f Theefoe the answe is Y X n 1!n 2! n k! n 1!n 2! n k! Coollay 43 The numbe of 0-1 wods of length n with exactly ones and n zeos is equal to!(n! Example 42 How many possibilities ae thee fo 8 non-attacking ooks on an 8-by-8 chessboad? How about having 8 diffeent colo ooks? How about having 1 ed (R ook, 3 blue (B ooks, and 4 yellow (Y ooks We label each squae by an odeed pai (i, j of coodinates, (1, 1 (i, j (8, 8 Then the ooks must occupy 8 squaes with coodinates (1, a 1, (2, a 2,, (8, a 8, whee a 1, a 2,, a 8 must be distinct, ie, a 1 a 2 a 8 is a pemutation of {1, 2,, 8} Thus the answe is When the 8 ooks have diffeent colos, the answe is ( 2 If thee ae 1 ed ook, 2 blue ooks, and 3 yellow ooks, then we have a multiset M {R, 3B, 4Y } of ooks The numbe of pemutations of M equals 1!3!4!, and the answe in question is 1!3!4! Theoem 44 Given n ooks of k colos with n 1 ooks of the fist colo, n 2 ooks of the second colo,, and n k ooks of the kth colo The numbe of ways to aange these ooks on an n-by-n boad so that no two ooks can attack anothe equals n 1!n 2! n k! ( 2 n 1!n 2! n k! Example 43 Find the numbe of 8-pemutations of the multiset M {a, a, a, b, b, c, c, c, c} {3a, 2b, 4c} The numbe of 8-pemutations of {2a, 2b, 4c}: 2!2!4! The the numbe of 8-pemutations of {3a, b, 4c}: The numbe of 8-pemutations of {3a, 2b, 3c}: Thus the answe is 5 Combinations of Multisets 3!1!4! 3!2!3! 2!2!4! + 3!1!4! + 420 + 280 + 560 1, 260 3!2!3! Let M be a multiset An -combination of M is an unodeed collection of objects fom M Thus an -combination of M is itself an -submultiset of M Fo a multiset M { a 1, a 2,, a n }, an -combination of M is also called an -combination with epetition allowed of the n-set S {a 1, a 2,, a n } The numbe of -combinations with epetition allowed of an n-set is denoted by n Theoem 51 Let M { a 1, a 2,, a n } be a multiset of n types Then the numbe of -combinations of M is given by ( ( n n + 1 n + 1 n 1 Poof When objects ae taken fom the multiset M, we put them into the following boxes 1st 2nd nth 6
so that the ith type objects ae contained in the ith box, 1 i n Since the objects of the same type ae indistinguishable, we may use the symbol O to denote any object in the boxes, and the objects in diffeent boxes ae sepaated by a stick Convet the symbol O to zeo 0 and the stick to one 1, any such placement is conveted into a 0-1 sequence of length + n 1 with exactly zeos and n 1 ones Fo example, fo n 4 and 7, OO O OOO O {a, a, b, c, c, c, d} 0010100010 1 2 3 4 {b, b, b, b, d, d, d} OOO OOO 1 2 3 4 1000011000 Now the poblem becomes counting the numbe of 0-1 wods of length + (n 1 with exactly zeos and n 1 ones Thus the answe is ( ( n n + 1 n + 1 n 1 Coollay 52 The numbe n equals the numbe of ways to place identical balls into n distinct boxes Coollay 53 The numbe n equals the numbe of nonnegative intege solutions of the equation x 1 + x 2 + + x n Coollay 54 The numbe n equals the numbe of nondeceasing sequences of length whose tems ae taken fom the set {1, 2,, n} Example 51 Find the numbe of nonnegative intege solutions fo the equation x 1 + x 2 + x 3 + x 4 < 19 The poblem is equivalent to finding the numbe of nonnegative intege solutions of the equation x 1 + x 2 + x 3 + x 4 + x 5 18 7