- StudyBlue
- Kansas
- University of Kansas
- Electrical Engineering
- Electrical Engineering 210
- Kinnersley
- Lecture 10: Fundamentals of Counting

Anonymous

Advertisement

Advertisement

1 Lecture 10: Fundamentals of Counting Read: Chpt.5.1-5.5, 7.5, Rosen Consider that we are performing two experiments A and B with A having m possible outcomes a 1 , a 2 , ?, a m and B having n possible outcomes b 1 , b 2 , ?, b n . Q: What are the possible outcomes if we are to perform either A or B, but not both, and what are the possible outcomes if we are to perform both A and B? Possible Outcomes: ? Either A or B: {a 1 , a 2 , ?, a m , b 1 , b 2 , ?, b n }. # possible outcomes = |A| + |B| = m + n. ? Both A and B: {(a 1 ,b 1 ), (a 1 ,b 2 ), ?, (a 1 ,b n ), (a 2 ,b 1 ), (a 2 ,b 2 ), ?, (a 2 ,b n ), ? (a m ,b 1 ), (a m ,b 2 ), ?, (a m ,b n )}. # possible outcomes = |A| * |B| = m ? n. Q: What if we are performing k tasks (experiments) A 1 , A 2 , ?, A k such that there are n i ways (outcomes) to perform task A i , 1 ? i ? k? 2 1. Two Basic Counting Principles: The Rule of Sum: There are n 1 + n 2 + ? + n k ways to perform exactly one of these k tasks. The Rule of Product: There are n 1 ? n 2 ? ? ? n k ways to perform all of these k tasks. Applications: 1. A menu in a local deli offers 6 soda, 10 sandwiches, 12 desserts. #ways to order a soda: 6. #ways to order exactly one item: 6 + 10 + 12 = 28. #ways to order a full meal (soda + sandwiches + dessert): 6 ? 10 ? 12 = 720. #ways to order a soda and a sandwich: 6 ? 10. #ways to order any two items: 28 ? 28 = 784. #ways to order any two distinct items: 28 ? 27 = 756. #ways to order two items of different kind: (6 ? 10) + (10 ? 12) + (6 ? 12) = 252. 3 2. An electronic lock uses a 7-digit code to operate it. #possible codes: 10 7 . #possible codes starting with 0: 1?10 6 . #possible codes not starting with 0: 9?10 6 . (#possible codes ? #possible codes starting with 0 = 10 7 ? 10 6 = 9?10 6 .) #possible codes starting with 0, or 1, or 2: 3?10 6 . #possible codes starting and ending with 0: 1?10 5 ?1. #possible codes starting or ending with 0 but not both: (1?10 5 ?9) + (9?10 5 ?1) #possible codes starting with 1, 3, 5 or ending with 2, 8: 3?10 6 + 10 6 ?2 ? 3?10 5 ?2 #possible codes starting with 1, 3, 5 or ending with 2, 8 but not both: (3?10 5 ?8) + (7?10 5 ?2) 4 3. In Fortran, an identifier consists of a character string with 1 to 7 characters such that the first character must be a letter chosen from {a, b, ?, z}, followed by up to 6 more letter(s) and/or digits. Q: How many different identifiers are there? Let P be the # of all possible identifiers, P 1 be the # of all identifiers with exactly 1 char, P 2 be the # of all identifiers with exactly 2 chars, ? P 7 be the # of all identifiers with exactly 7 chars. P 1 = 26, // 26 ways to chose the 1 st char P 2 = 26?36, // 36 ways to chose the 2 nd char P 3 = 26?36 2 , // 36 2 ways to chose the 2 nd & 3 rd chars ? P 7 = 26?36 6 . // 36 6 ways to chose the 2 nd to 7 th chars ? P = P 1 + P 2 + ? + P 7 = 26?(36 0 + 36 1 + ? + 36 6 ) = 26?( 7 36 1 36 1 ? ? ) ? 5.82×10 10 . Practice HW: Chpt.5.1, 3, 5, 21, 23, 25, 27, 29, 31, 35. 5 2. The Pigeonhole Principle: Theorem: If k+1 objects (pigeons) are to be placed in k boxes (pigeonholes), then at least one of the k boxes must contain two or more of the given objects. Proof. (Proof by Contradiction) Assume that k+1 objects are placed in the k boxes but none of the k boxes contains more than one object to obtain a contradiction. Since each box contains at most one object, the maximum number of objects in these k boxes must be ? k, which contradicts to the assumption that there are k+1 objects in the k boxes. Hence, the Pigeonhole Principle holds. Remark: This is also known as Shoebox Principle, or Dirichlet Principle. Applications: 1. Among 13 people in a party, 2 of them must have their birthday in a same month. 2. Among 102 students taking an exam (max = 100 points), 2 of them must have same score. 3. Given 210 pairs of married couples (420 people). A minimum of 211 people must be invited so as to guarantee that at least a married couple will be included. 6 More Interesting Applications: 4. Given any m arbitrary positive integers a 1 , a 2 , ?, a m , m ? 1. Prove that there exist integers i, j, 0 ? i < j ? m, such that the sum a i+1 + a i+2 + ? + a j is divisible by m. Proof. Define the following partial sums: S 1 = a 1 , S 2 = a 1 + a 2 , ? S m = a 1 + a 2 + ? + a m . Consider the following two cases. Case 1: If ? k, 1 ? k ? m, such that m ?S k , we can choose i = 0 and j = k. Case 2: Assume that ? k, 1 ? k ? m, m ? S k . By Division Theorem, we must have S 1 = mq 1 + r 1 , 1 ? r 1 ? m ?1, S 2 = mq 2 + r 2 , 1 ? r 2 ? m ?1, ? S m = mq m + r m , 1 ? r m ? m ?1. Observe that there are m remainders r 1 , r 2 , ?, r m but only m ?1 values for them to choose from. Hence, by Pigeonhole Principle, two of the m remainders must be the same! WOLOG (WithOut Loss Of Generality), let r s = r t = r, and 1 ? s < t ? m. 7 Hence, we have S s = mq s + r, and S t = mq t + r. ? S t ? S s = m(q t ? q s ) and m ?S t ? S s . By construction, S t ? S s = (a 1 + a 2 + ?+ a s + ? + a t ) ? (a 1 + a 2 + ? + a s ) = (a s+1 + a i+2 + ? + a t ). Hence, m ?(a s+1 + a i+2 + ? + a t ) and we can then choose i = s and j = t. Since both cases lead to the conclusion that ? i, j, 0 ? i < j ? m, such that m ?(a i+1 + a i+2 + ? + a j ), the assertion must be true. 8 5. A chess grandmaster has 11 weeks to prepare for a tournament and he/she has decided to play at least 1 game each day but no more than 12 games during any 7 consecutive days. Prove that there must be a period of consecutive days during which the grandmaster will play exactly 21 games. Proof. There are 77 days in 11 weeks. Let a 1 be the total #games played on the first day, a 2 be the total #games played on the first two days, ? a 77 be the total #games played on the first 77 days. ? 1 ? a 1 < a 2 < ? < a 77 ? 11?12 = 132, and 22 ? a 1 +21 < a 2 +21 < ? < a 77 +21 ? 153. (Why?) Every one of the numbers {a 1 , a 2 , ?, a 77 , a 1 +21, a 2 +21, ?, a 77 +21 } must satisfy the following inequality: 1 ? a 1 , a 2 , ?, a 77 , a 1 +21, a 2 +21, ?, a 77 +21 ? 153. Since these 154 numbers are between 1 and 153, by Pigeonhole Principle, at least two of them must be the same. Hence, ? i, j ? N, 1 ? i < j ? 77, such that a j = a i + 21. (Why?) Hence, a j ? a i = 21 and, from day (i+1) to day j, the master must have played exactly 21 games. 9 6. Consider the set S = {1, 2, ?, 2n}. Prove that among any arbitrarily chosen n+1 integers from S, there must exists a pair of integers x and y such that x ?y. Proof. Let x 1 , x 2 , ?, x n+1 be any n+1 integers arbitrarily chosen from S. By factoring out as many 2?s from each integer, each integer x i , 1 ? i ? n+1, can be written as: x i = 2 ki q i , where k i ? 0 is an integer and q i is an odd integer with 1 ? q i ? 2n?1. Examples: 28 = 2 2 7, 39 = 2 0 39. Consider these n+1 odd integers q 1 , q 2 , ?, q n+1 . Since q i is an odd integer with 1 ? q i ? 2n?1 and there are at most n distinct values for the q i ?s, ? i, j, 1 ? i < j ? n+1, such that q i = q j = q. Consider the integers x i = 2 ki q and x j = 2 kj q. WOLOG, let x i < x j . Hence, k i < k j . (Why?) ? x j = 2 kj q = (2 ki 2 (kj?ki) )q = (2 ki q)2 (kj?ki) = x i 2 (kj?ki) Since 2 (kj?ki) ? N, we have x i ?x j . By choosing x = x i and y = x j , we have the assertion. 10 Extension: Generalized Pigeonhole Principle: If m objects are to be placed in n boxes, m ? n, then there exists at least one box containing at least ? n m ? objects. Special cases: 1. If m = n + 1, we have the Pigeonhole Principle. 2. If m = kn + 1, then there exists at least one box containing at least k + 1 objects. Applications: 1. If there are 37 people in a party, at least how many of them were born in the same month? Since m = 37, n = 12, # people born in the same month ? ? 37 12 ? = 4. 2. At least how many guests you must invite in order to guarantee that 6 of them were born in the same month? Since ? n m ? = 6 with n = 12, m = 61. Hence, at least 61 guests must be invited. Another Approach: Since n = 12 and k + 1 = 6 (or k = 5), m = kn + 1 = 5?12 + 1 = 61. 11 3. Assume that there are infinitely that many red, white, and blue socks in a laundry basket. Q: How many socks one must select to guarantee 3 pairs of socks of the same color? Since n = 3, k + 1 = 6 (or k = 5), m = kn + 1 = 5?3 + 1 = 16. Hence, at least 16 socks must be selected. Q: How many socks one must select to guarantee 3 pairs of red socks? Infinity! 4. Prove that in a party of six, either 3 of them are mutual friends or 3 of them are complete strangers to each other. Proof. Let A be any person in the group. Among the 5 remaining people, by Generalized Pigeonhole Principle, either 3 or more of them are friends of A, or 3 or more of them are strangers to A. Case 1: Let B, C, D be friends of A. If two of them are friends, together with A, we have 3 mutual friends. Else, they are 3 complete strangers to each other as required. Case 2: Let B, C, D be strangers to A. If 2 of them are strangers to each other, together with A, we have 3 complete strangers. Else, they are 3 mutual friends as required. Practice HW: Chpt.5.2, 3, 7, 9, 13, 17, 19, 21, 25. 12 3. Permutation and Combination: Let?s consider the ordered arrangements of three distinct objects a, b, and c. They are: abc acb bac bca cab cba Each one of these arrangements is a permutation of {a,b,c}. Dfn: Given a set of n distinct objects S. An r-permutation of S, r ? n, is an ordered arrangement (selection/placement) of any r elements of S. Let P(n,r), n r P , be the # of r-permutations of n objects. Example: Let S = {a,b,c}. P(3,1) = 3, P(3,2) = 6, P(3,3) = 6. 13 Q: How do we compute P(n,r)? Observe that we have n choices for the 1 st object, n?1 choices for the 2 nd object, n?2 choices for the 3 rd object, ? n?r+1 choices for the r th object. Hence, P(n,r) = n(n?1)(n?2)?(n?r+1) = (n) r , (falling factorial function) = ! ()! n nr? . Observe that P(n,n) = n!, P(n,0) = 1, P(0,0) = 1. Applications: 1. In how many different ways can a 5-character string be formed from {a, b, c, d, e, f, g}? P(7,5) = 7! 2! = 7?6?5?4?3 = 2,520 14 2. There are 30 members in a social club. In how many different ways can a committee with 1 chairperson, 1 vice-chairperson, 1 secretary, and 1 treasurer be formed? P(30,4) = 30! 26! = 657,720 3. Given S = {2, 3, 5, 7, 9}. (a) How many distinct 3-digit integers can be formed? P(5,3) = 5! 2! = 60 (b) How many of these integers are less than 500? 2 ways to choose the 1 st digit, 4 ways to choose the 2 nd digit, 3 ways to choose the 3 rd digit, ? # distinct 3-digit integers < 500 = 2?4?3 =24 (c) How many of these distinct 3-digit integers are odd? 3?4?4 =48 (d) How many 3-digit integers < 500 are odd? 24 ? 3 = 21 (Why?) 15 Let?s now consider the unordered arrangements of distinct objects. Dfn: Given a set S of n distinct objects. An r-combination of S is an unordered arrangement (selection/placement) of r. Let C(n,r) = n r C = () n r be the # r-combinations of n objects. Example: Let S = {a,b,c}. 1-combination of S: a, b, c 2-combination of S: ab, ac, bc 3-combination of S: abc C(3,1) = 3, C(3,2) = 3, C(3,3) = 1. 16 Q: How do we compute C(n,r)? Theorem: P(n,r) = C(n,r)?P(r,r). Proof. To orderly arrange r objects in S, we may first select, without regarding to order, any r objects and then orderly arrange these r objects in all possible ways. Hence, P(n,r) = C(n,r)?P(r,r). Corollary: C(n,r) = (,) (,) Pnr Prr = ! ()!! n nrr? = C(n,n-r). Applications: 1. In how many different ways can a committee of 5 be formed among 30 members? C(30,5) = 30! 25!5! = 142,506 2. A menu has 6 sodas, 10 sandwiches and 5 desserts. In how many different ways can we order 3 sodas, 5 sandwiches and 2 desserts? C(6,3)?C(10,5) ?C(5,2) = 50,400 17 3. A student must answer 10 out of 13 questions in an exam. (a) How many different ways can he/she take this exam? C(13,10) = 286 (b) What if he must answer the first 2 questions? C(11,8) = 165 (c) What if he must answer either the first or second, but not both, questions? C(2,1)?C(11,9) = 110 (d) What if he must answer exactly 3 out of the first 5 questions? C(5,3) ?C(8,7) = 80 (e) What if he must answer at least 3 out of the first 5 questions? C(5,3) ?C(8,7) + C(5,4) ?C(8,6) + C(5,5) ?C(8,5) = 276 4. Pascal Identity: C(n,r) = C(n-1,r) + C(n-1,r-1). Proof. Let x be any object in S. Any selection of r objects from S will either include or exclude x. If x is included, #ways to select the remaining r-1 objects is C(n-1,r-1). If x is excluded, #ways to select the r objects is C(n-1,r). Hence, by Sum Rule, we have C(n,r) = C(n-1,r) + C(n-1,r-1). Practice HW: Chpt.5.3, 13, 15, 17, 21, 25, 27, 33, 39. 18 4. The Principle of Inclusion and Exclusion: For finite sets A, B, |A ? B| = |A| + |B| ? |A ? B|. For finite sets A, B, C. |A ? B ? C| = |A| + |B| + |C| ? |A ? B| ? |B ? C| ? |A ? C| + | A ? B ? C|. ? In general, for finite sets A 1 , A 2 , ?, A n , |A 1 ? A 2 ? ? ? A n | = ? 1?i?n |A i | ? ? 1?i n, there is no injection from A to B. (f) If m ? n, there are (n) m injections from A to B. Q: How many surjections are there from A to B? (g) If m < n, there is no surjection from A to B. 23 (h) If m ? n, the number of surjections from A to B is: 1 ( ,1)( 1) ( ,2)( 2) ... ( 1) ( , 1)1 . mm mnm nCnn Cnn Cnn ? ??+??+? ? Proof. Let B = {b 1 , b 2 , ?, b n }. If a function f from A to B is not a surjection, one or more b i ?s must not have a pre-image in A. Define: P 1 be the property that b 1 has no pre-image in A, P 2 be the property that b 2 has no pre-image in A, ? P n be the property that b n has no pre-image in A. Hence, # of surjections = N(P 1 ?P 2 ??P n ?) = n m ? ? 1?i?n N(P i ) + ? 1?i

Want to see the other 44 page(s) in Lecture 10: Fundamentals of Counting?
JOIN TODAY FOR FREE!

"The semester I found StudyBlue, I went from a 2.8 to a 3.8, and graduated with honors!"

Jennifer Colorado School of Mines
StudyBlue is not sponsored or endorsed by any college, university, or instructor.

© 2015 StudyBlue Inc. All rights reserved.

© 2015 StudyBlue Inc. All rights reserved.