Download presentation

Presentation is loading. Please wait.

Published byJosh Crabbe Modified about 1 year ago

1
Discrete Mathematics Chapter 5 Counting

2
Ch5-2 A counting problem: (Example 15) Each user on a computer system has a password, which is six to eight characters long, where each characters is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there? This section introduces a variety of other counting problems the basic techniques of counting. §5.1 The Basics of counting

3
Ch5-3 Basic counting principles The sum rule: If a first task can be done in n 1 ways and a second task in n 2 ways, and if these tasks cannot be done at the same time. then there are n 1 +n 2 ways to do either task. Example 11 Suppose that either a member of faculty or a student is chosen as a representative to a university committee. How many different choices are there for this representative if there are 37 members of the faculty and 83 students? n1n1 n2n2 n 1 + n 2 ways

4
Ch5-4 Example 12 A student can choose a computer project from one of three lists. The three lists contain 23, 15 and 19 possible projects respectively. How many possible projects are there to choose from? Sol: =57 projects. The product rule: Suppose that a procedure can be broken down into two tasks. If there are n 1 ways to do the first task and n 2 ways to do the second task after the first task has been done, then there are n 1 n 2 ways to do the procedure. n1n1 n2n2 n 1 × n 2 ways

5
Ch5-5 Example 2 The chair of an auditorium ( 大礼堂 ) is to be labeled with a letter and a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently? Sol: 26 × 100 = 2600 ways to label chairs. letter Example 4 How many different bit strings are there of length seven? Sol: □ □ □ □ □ □ □ ↑ ↑ ↑ ↑ ↑ ↑ ↑ 0,1 0,1 0, ,1 → 2 7 种

6
Ch5-6 Example 5 How many different license plates ( 车牌 ) are available if each plate contains a sequence of 3 letters followed by 3 digits ? Sol: □ □ □ □ □ □ → 26 3 ． 10 3 letter digit Example 6 How many functions are there from a set with m elements to one with n elements? Sol: f(a 1 )=? 可以是 b 1 ～ b n, 共 n 种 f(a 2 )=? 可以是 b 1 ～ b n, 共 n 种 ： f(a m )=? 可以是 b 1 ～ b n, 共 n 种 ∴ n m a1a2．．．ama1a2．．．am b1b2．．．bnb1b2．．．bn f

7
Ch5-7 Example 7 How many one-to-one functions are there from a set with m elements to one with n element? ( m n ) Sol: f(a 1 ) = ? 可以是 b 1 ～ b n, 共 n 种 f(a 2 ) = ? 可以是 b 1 ～ b n, 但不能 = f(a 1 ), 共 n 1 种 f(a 3 ) = ? 可以是 b 1 ～ b n, 但不能 = f(a 1 ), 也不能 = f(a 2 ), 共 n 2 种 ： ： f(a m ) = ? 不可 f(a 1 ), f(a 2 ),..., f(a m 1 ), 故共 n (m 1) 种 ∴共 n ． (n 1) ． (n 2) ．... ． (n m+1) 种 1-1 function #

8
Ch5-8 Example 15 Each user on a computer system has a password which is 6 to 8 characters long, where each character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there? Sol: P i : # of possible passwords of length i, i=6,7,8 P 6 = 36 6 26 6 P 7 = 36 7 26 7 P 8 = 36 8 26 8 ∴ P 6 + P 7 + P 8 = 26 6 26 7 26 8 种

9
Ch5-9 Example 14 In a version of Basic, the name of a variable is a string of one or two alphanumeric characters, where uppercase and lowercase letters are not distinguished. Moreover, a variable name must begin with a letter and must be different from the five strings of two characters that are reserved for programming use. How many different variable names are there in this version of Basic? Sol: Let V i be the number of variable names of length i. V 1 =26 V 2 =26 ． 36 – 5 ∴ ． 36 – 5 different names.

10
Ch5-10 ※ The Inclusion-Exclusion Principle ( 排容原理 ) A B Example 17 How many bit strings of length eight either start with a 1 bit or end with the two bits 00 ? Sol: １ ２ ３ ４ ５ ６ ７ ８ □ □ □ □ □ □ □ □ ↑ ↑ ① 1 0,1 0,1 → 共 2 7 种 ② → 共 2 6 种 ③ → 共 2 5 种 2 5 种

11
Ch bit 1 ※ Tree Diagrams Example 18 How many bit strings of length four do not have two consecutive 1s ? Sol: Exercise: 11, 17, 23, 27, 38, 39, 47, (0000) (0001) (0010) (0100) (0101) (1000) (1001) (1010) ∴ 8 bit strings bit 3

12
Ch5-12 Ex 38. How many subsets of a set with 100 elements have more than one element ? Sol: Ex 39. A palindrome ( 回文 ) is a string whose reversal is identical to the string. How many bit strings of length n are palindromes ? ( abcdcba 是回文, abcd 不是 ) Sol: If a 1 a 2... a n is a palindrome, then a 1 =a n, a 2 =a n 1, a 3 =a n 2, … Thm. 4 of §4.3 放 不放 放 不放 放 不放 空集合及 只有 1 个元素的集合

13
Ch5-13 §5.2 The Pigeonhole Principle ( 鸽笼原理 ) Theorem 1 (The Pigeonhole Principle) If k+1 or more objects are placed into k boxes, then there is at least one box containing two or more of the objects. Proof Suppose that none of the k boxes contains more than one object. Then the total number of objects would be at most k. This is a contradiction. Example 1. Among any 367 people, there must be at least two with the same birthday, because there are only 366 possible birthdays.

14
Ch5-14 Example 2 In any group of 27 English words, there must be at least two that begin with the same letter. Example 3 How many students must be in a class to guarantee that at least two students receive the same score on the final exam ? (0~100 points) Sol: 102. (101+1) Theorem 2. (The generalized pigeon hole principle) If N objects are placed into k boxes, then there is at least one box containing at least objects. e.g. 21 objects, 10 boxes there must be one box containing at least objects.

15
Ch5-15 Example 5 Among 100 people there are at least who were born in the same month. ( 100 objects, 12 boxes )

16
Ch5-16 Example 10 During a month with 30 days a baseball team plays at least 1 game a day, but no more than 45 games. Show that there must be a period of some number of consecutive days during which the team must play exactly 14 games. day # of game3212 存在一段时间的 game 数和 =14 ( 跳过 )

17
Ch5-17 Sol: Let a j be the number of games played on or before the jth day of the month. ( 第 1 天～第 j 天的比赛数和 ) Then is an increasing sequence of distinct integers with Moreover, is also an increasing sequence of distinct integers with There are 60 positive integers between 1 and 59. Hence, such that ( 跳过 )

18
Ch5-18 Def. Suppose that is a sequence of numbers. A subsequence of this sequence is a sequence of the form where e.g. sequence: 8, 11, 9, 1, 4, 6, 12, 10, 5, 7 subsequence: 8, 9, 12 ( ) 9, 11, 4, 6 ( ) Def. A sequence is called increasing ( 递增 ) if A sequence is called decreasing ( 递减 ) if A sequence is called strictly increasing ( 严格递增 ) if A sequence is called strictly decreasing ( 严格递减 ) if

19
Ch5-19 Theorem 3. Every sequence of n 2 +1 distinct real numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. Example 12. The sequence 8, 11, 9, 1, 4, 6, 12, 10, 5, 7 contains 10= terms (i.e., n =3). There is a strictly increasing subsequence of length four, namely, 1, 4, 5, 7. There is also a decreasing subsequence of length 4, namely, 11, 9, 6, 5. Exercise 21 Construct a sequence of 16 positive integers that has no increasing or decreasing subsequence of 5 terms. Sol: Exercise: 5, 13, 15, 31 ( 跳过 )

20
Ch5-20 §5.3 Permutations( 排列 ) and Combinations( 组 合 ) Def. A permutation of a set of distinct objects is an ordered arrangement of these objects. An ordered arrangement of r elements of a set is called an r -permutation. Example 2. Let S = {1, 2, 3}. The arrangement 3,1,2 is a permutation of S. The arrangement 3,2 is a 2-permutation of S. Theorem 1. The number of r -permutation of a set with n distinct elements is 位置： … r □ □ □ … □ 放法： …

21
Ch5-21 Example 4. How many different ways are there to select a first-prize winner ( 第一名 ), a second-prize winner, and a third-prize winner from 100 different people who have entered a contest ? Sol: Example 6. Suppose that a saleswoman has to visit 8 different cities. She must begin her trip in a specified city, but she can visit the other cities in any order she wishes. How many possible orders can the saleswoman use when visiting these cities ? Sol:

22
Ch5-22 Def. An r -combination of elements of a set is an unordered selection of r elements from the set. Example 9 Let S be the set {1, 2, 3, 4}. Then {1, 3, 4} is a 3 -combination from S. Theorem 2 The number of r -combinations of a set with n elements, where n is a positive integer and r is an integer with, equals pf : 称为 binomial coefficient

23
Ch5-23 Example 10. We see that C(4,2)=6, since the 2-combinations of {a,b,c,d} are the six subsets {a,b}, {a,c}, {a,d}, {b,c}, {b,d} and {c,d} Corollary 2. Let n and r be nonnegative integers with r n. Then C(n,r) = C(n,n r) pf : From Thm 2. 组合意义：选 r 个拿走, 相当于是选 n r 个留下.

24
Ch5-24 Example 12. How many ways are there to select 5 players from a 10-member tennis team to make a trip to a match at another school ? Sol: C(10,5)=252 Example 15. Suppose there are 9 faculty members in the math department and 11 in the computer science department. How many ways are there to select a committee if the committee is to consist of 3 faculty members from the math department and 4 from the computer science department? Sol: Exercise: 3, 11, 13, 21, 33, 34.

25
Ch5-25 §5.4 Binomial Coefficients ( 二项式系数 ) Example 1. 要产生 xy 2 项时， 需从三个括号中选两个括号提供 y ，剩下一个则提供 x ( 注意：同一个括号中的 x 跟 y 不可能相乘 ) ∴共有 种不同来源的 xy 2 ∴ xy 2 的系数 = Theorem 1. (The Binomial Theorem, 二项式定理 ) Let x,y be variables, and let n be a positive integer, then

26
Ch5-26 Example 4. What is the coefficient of x 12 y 13 in the expansion of ? Sol: ∴ Cor 1. Let n be a positive integer. Then pf : By Thm 1, let x = y = 1 Cor 2. Let n be a positive integer. Then pf : by Thm 1. (1 1) n = 0

27
Ch5-27 Theorem 2. (Pascal’s identity) Let n and k be positive integers with n k Then PASCAL’s triangle … …

28
Ch5-28 pf : ① (algebraic proof, 代数证明 ) n ‧ 1 k 取法 = 1 k n ‧ 0 1 k1k1 + n ‧ 1 ② (combinatorial proof, 组合意义证明 ):

29
Ch5-29 Theorem 3. (Vandermode’s Identity) pf : mn r C(m+n, r) = m n m n m n ↓ ↓ + ↓ ↓ ↓ ↓ r, 0 r 1, 1 0, r =

30
Ch5-30 Ex 33. Here we will count the number of paths between the origin (0,0) and point (m,n) such that each path is made up of a series of steps, where each step is a move one unit to the right or a more one unit upward (5,3) (0,0) Red path 对应的字符串 : Each path can be represented by a bit string consisting of m 0 s and n 1 s. (→) (↑) There are paths of the desired type. Exercise: 7, 21, 28

31
Ch5-31 §5.5 Generalized Permutations and Combinations Thm 1. The number of r -permutations of a set of n objects with repetition allowed is n r. Permutations with Repetition Example 1 How many strings of length r can be formed from the English alphabet? Sol. 26 r

32
Ch5-32 Combinations with Repetition Example 3 How many ways are there to select five bills from a cash box containing $1 bills, $2 bills, $5 bills, $10 bills, $20 bills, $50 bills, and $100 bills? ( 假设顺序不计、同面额不区分、每种面额至少五张 ) Sol. 7 种面额需 6 个 bar 隔开，故 6 个 bar 跟 5 张 bill 组合 C(11, 5) 面额 张数 可用字符串 | | | | | | 代表 可用字符串 | | | | | | 代表 可用字符串 | | | | | | 代表 … 的个数 表示张数 隔开的 bar

33
Ch5-33 ∴ 种方法 # Thm 2. There are C(r+n 1, r) r -combinations from a set with n elements when repetition of elements is allowed. ＊＊｜＊｜｜＊＊＊ a 1 出现 2 次 a 2 出现 1 次 a 3 不出现 a 4 出现 3 次 取法 例： 设 n = 4, 集合为, r = 6 pf : ( 视为有 r 个＊，要放入 n 个区域， 故需插入 n 1 个 bar 将这些＊隔成 n 区 )

34
Ch5-34 Example 4. Suppose that a cookie shop has 4 different kinds of cookies. How many different ways can 6 cookies be chosen? Sol: 6 个 cookie 插入 3 个 bar 种 Example 5. How many solutions does the equation x 1 + x 2 + x 3 = 11 have, where x 1, x 2, x 3 are nonnegative integers?’ Sol: 11 个 1 间要插入 2 个 bar 种

35
∴共有 种 ∴ 5 个 1 间要插入 2 个 bar 种 Ch5-35 因 ( x 1 4) + (x 2 2) + (x 3 3) = 11 9 = 2 ※若上题改要求 x 1 1, x 2 2, x 3 3, 则原式 x 1 + x 2 + x 3 = 11 可改成 ( x 1 1) + (x 2 2) + (x 3 3) = 11 1 2 3 = 5 此时相当于是 y 1 + y 2 + y 3 = 5 其中 y 1 = x 1 1, y 2 = x 2 2, y 3 = x 3 3 且 y 1, y 2, y 3 N ( 注意： case y 1 = 1, y 2 = 3, y 3 = 1 相当于 x 1 =2, x 2 =5, x 3 =4) ※若上题再改为 1 x 1 3, x 2 2, x 3 3 ，则需排除 x 1 > 3 的情形 ( 即 x 1 4 的情形 ) Exercise: 15, 20, 25

36
Ch5-36 Example 7. How many different strings can be made by reordering the letters of the word SUCCESS ? Sol: 有 3 个 S, 2 个 C, 1 个 U 及 1 个 E, 可放 S 的位置有 种 剩下的 4 个位置中可放 C 的有 种 剩下的 2 个位置中可放 U 的有 种 剩下的 1 个位置中可放 E 的有 种 ∴共 种 ※ Permutations with indistinguishable objects

37
Thm 3. The number of different permutations of n objects, where type 1 ： n 1 种 type 2 ： n 2 种 is type k ： n k 种 Ch5-37 pf : Exercise: 17, 31, 36, 65

38
Ch5-38 Example 8. How many ways are there to distribute hands of 5 cards to each of four players from the standard deck of 52 cards? Sol: player 1 ： 种 player 2 ： 从剩下的牌再发 5 张 Distributing objects into Boxes 注意：上题相当于将 52 张牌放进 5 个不同的 box 的放法, 即 box 1 的给 player 1 box 2 的给 player 2 box 3 的给 player 3 box 4 的给 player 4 而 box 5 的是剩下的牌. Distinguishable Objects and distinguishable boxes Exercise: 45

39
Ch5-39 Thm 4. The number of ways to distribute n distinguishable objects into k distinguishable boxes so that n i objects are placed into box i, i=1, 2, …, k, equals ( 跟 Thm 3 相等 ) Example 9. How many ways are there to place 10 indistinguishable balls into eight distinguishable bins? Sol: C(8+10 1, 10) Indistinguishable Objects and distinguishable boxes There are C(n+r 1, n 1) ways to place r indistinguishable objects into n distinguishable boxes.

40
Ch5-40 Distinguishable Objects and indistinguishable boxes Example 10. How many ways are there to put four different employees into three indistinguishable offices, when each office can contain any number of employees? Sol: employees: A, B, C, D 4 人在同一 office: {{A, B, C, D}} 1 种 3 人在同一 office, 1 人在另一 office: {{A, B, C}, {D}}, {{A, B, D}, {C}}, … 4 种 2 人在同一 office, 2 人在另一 office: {{A, B}, {C, D}}, {{A, D}, {B, C}}, … 3 种 2 人在同一 office, 另 2 人分别在剩下两个 office: {{A, B}, {C}, {D}}, {{A, D}, {B}, {C}}, … 6 种 共 14 种 Note. There is no simple closed formula. 可参考 Stirling numbers of the second kind. (p. 378)

41
Ch5-41 Indistinguishable Objects and indistinguishable boxes Example 11. How many ways are there to pack six copies of the same book into four identical boxes, where a box can obtain as many as six books? Sol: 6 5, 1 共 9 种 Note. This problem is the same as writing n as the sum of at most k positive integers in nonincreasing order. That is, a 1 +a 2 +…+a j = n, where a 1, a 2, …, a j are positive integers with a 1 a 2 … a j and j k. No simple closed formula exists. 4, 2 4, 1, 1 3, 3 3, 2, 1 3, 1, 1, 1 2, 2, 2 2, 2, 1, 1

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google