Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 1 Fundamental Principles of Counting Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004.

Similar presentations


Presentation on theme: "1 Chapter 1 Fundamental Principles of Counting Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004."— Presentation transcript:

1 1 Chapter 1 Fundamental Principles of Counting Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004

2 2 Issues of Counting How many license plates like AB-1234 are there? How many 16 digits credit card numbers are there such that they always have at least two different digits? What is the coefficient of x 2 y 3 z 4 in the expansion of (x+y+z) 9 ? Applications: coding theory, probability and statistics, and analysis of algorithms.

3 3 “ If a first task can be performed in m ways, while a second task can be performed in n ways, and two tasks cannot be performed simultaneously, then performing either task can be accomplished in any one of m+n ways. ” Example: A class has 10 males and 5 females, picking a student from this class can be done in 10+5=15 ways. The Rule of Sum

4 4 The Rule of Product “ If a procedure can be broken down into two stages, and there are m possible outcomes for the first stage and, for each of these outcomes, there are n possible outcomes for the second stage, then the total procedure can be carried out in mn ways. ” Example: A class has 20 males and 15 females, picking an opposite sex pair from this class can be done in 20×15 = 300 ways.

5 5 Examples How many 5-digit sequences are there such that no two consecutive digits are the same? Answer: 109999 = 65610. # How many 5-digit sequences are there such that no two digits are the same? Answer: 109876 = 30240. # How many functions f:{1, …,n}  {1, …,m}? Answer: m n. #

6 6 More Examples How many 12 digit credit card numbers are there such that they end with an even number or with “ 5 ” ? Answer: Numbers that end with even number: 10 11 5 Numbers that end with “ 5 ” : 10 11 Total: 10 11 5 + 10 11 = 600,000,000,000. #

7 7 Permutations In how many ways can you ‘line up’ a class of 35 students? Answer: 35×34×33×…×1 ≈ 1.0333148 × 1040, which is the number of permutations of 35 elements. # In how many ways can you ‘ line up ’ 20 students from a class of 35 students? Answer: 35×34× … ×16 ≈ 7.90192744 × 10 27. #

8 8 Permutations (Cont.) How many ways can you order n elements? Answer: n(n – 1)(n – 2) … 1 = n!. (say “ n factorial ” ) # Note: 0!=1, 1!=1, 2!=2, 3!=6, 4!=24, … How many ways can you order r out of n elements? Answer: n(n – 1)(n – 2) … (n – r+1) = n! / (n – r)!. Also denoted by P(n,r). #

9 9 How many 4-letter words out of “ desktop ” ? Answer: P(7,4) = 7!/3! = 840. How many 4-letter words out of “ website ” ? Answer: Not P(7,4) = 840, because of the two “ e ” s. 4-letter words with no or one “ e ” : P(6,4) = 360 (idea: make 4-letter words out of “ w e b s i t ” ) 4-letter words with two “ e ” s: 6 × P(5,2) = 120 (idea: positions of two “ e ” s gives 6 possibilities, the remaining two letter positions can be completed in P(5,2) = 20 ways from “ w b s i t ”.) Total: 360+120 = 480. # Examples

10 10 Permutations with Repetitions How many ways can you select r out of n positions? We just saw that n=4 and r=2 gives 6 possibilities: , , , , , . One way of re-phrasing it: “ How many strings of length n can you make out of r symbols  and n – r symbols  ? ” (This is not n! because many symbols are identical.) Another way of phrasing it: “ How many ways can you select r different numbers (=positions) out of {1,2, …,n}? (This is not P(n,r) because the order of choosing does not matter; e.g. picking 3,4 versus picking 4,3.)

11 11 Answer 1 How many n-strings can you make of r “  ” and n – r “  ” ? The answer would be n! if all  and  would be unique. Example for n=4 and r=2: Consider: , , ,  for which there are indeed 4!=24 combinations:    ,  ,  ,  ,  ,     Indeed 24/4=6.

12 12 Answer 1 (cont.) If all  and  are unique, the answer is n! Dividing this number by the factor of overcounts gives the right answer. The r symbols “  ” give an overcount factor of r!. The n – r symbols “  ” give an overcount factor of (n – r)!. Hence the right answer is:.

13 13 Answer 2 How many ways can you select r numbers out of 1,2, …,n? This is not P(n,r) as the order of choosing does not matter. Example for n=4, r=2: The P(4,2) = 12 ways of selecting two different numbers out of {1, …,4} are: (1,2), (2,1), (1,3), (3,1), (1,4), (4,1), (2,3), (3,2), (2,4), (4,2), (3,4), (4,3). The overcount factor is 2; the right answer is P(4,2)/2 = 6. In general, the overcount factor will be r!, hence we have again:.

14 14 Example How many routes are there from the lower-left corner to the upper-right corner of an mn grid in which we restricted to traveling only to the right or upward? Answer:. #

15 15 Combinations How many ways can you select r objects out of n? (without concern for the order of selection) Answer: Say: “n choose r”. Despite the fraction, C(n,r) will always be an integer.

16 16 Combinations Also: Because: we have

17 17 Summations The sum of a list of n+1 terms like a m, a m+1, …, a m+n, where m and n are integers and n0, is denoted by Sigma notation as lower limit: m upper limit: m+n index: i

18 18 Properties of Summations

19 19 Binomial Theorem Proof. Consider (x+y) n = (x+y)(x+y) … (x+y) with n factors. The coefficient of x k y n-k, where 0  k  n, is the number of different ways in which we select k x ’ s from n factors. The total number of such selections is C(n,k). # If x an y are variables and n is a positive integer, then

20 20 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 1 … Pascal’s Triangle

21 21 Corollary

22 22 More Combinations Q: How many 11-letter words out of “ M i s s i s s i p p i ” ? Answer: There is one “ m ”, four “ i ”, four “ s ”, and two “ p ” ; calculate the answer by positioning the letters by type: We can position the “ m ” in 11 ways (leaving 10 spots open), we can position the four “ i ” in C(10,4) ways, (6 spots open), we can position the four “ s ” in C(6,4) ways, (2 spots open), and we can position the two “ p ” in C(2,2) ways. Overall answer: C(11,1)×C(10,4)×C(6,4)×C(2,2) = 34650. Note, this equals: 11!/(1! 4! 4! 2!) = 34650. How to generalize?

23 23 Multinomial Theorem For positive integers n, t, the coefficient of in the expansion of (x 1 +x 2 + … +x t ) n is where each n i is an integer with 0n i n, for all 1  i  t, and n 1 + n 2 + … +n t = n. Proof. The coefficient of is the number of ways in which we select x 1 from n 1 of the n factors, x 2 from n 2 of the n-n 1 factors, …, x t from n t of the n - n 1 – n 2 - … - n t-1 = n t factors. The total number of such selections is #

24 24 Question: How many alphabetized strings are there of length 3 containing the letters a,b,c? Brute force answer: 10, namely: aaa, aab, aac, abb, abc, acc, bbb, bbc, bcc, and ccc. Slightly less brute force: Alphabetization: the only thing that matters is the multitude of the letters a,b,c. Introduce the 3 nonnegative counters n a n b and n c. How many combinations are there such that n a +n b +n c =3? Answer is 10: (3,0,0) (2,1,0) … (0,0,3). Another way of visualizing these 10 options is:  = (3,0,0) and  = (2,1,0) … and  = (1,1,1) … and  = (0,0,3). Answer: C(5,2) = 10 Combinations with Repetitions

25 25 Combinations with Repetitions Consider a list of k words, out of a dictionary of n words. How many different, alphabetized lists are possible? Answer: Let the 1 st word occurs k 1 times, the 2 nd word occurs k 2 times, …, the n th word k n times. How many different sums k 1 + … +k n = k are there? Consider k symbols “  ” with n – 1 separators “  ”, such that 3+0+2=5 is represented by “  ” (k=5, n=3). For given n and k, there are C(n+k – 1,k) possibilities.

26 26 Summary When counting the number if selections of k elements out of 1, …,n, consider two crucial questions: Repetition: Can an element be picked more than once? Order: Is the order of picking relevant? Ordering relevant? Repetition allowed? yesno yes n k (Arrangement) P(n,k) (Permutation) no C(n+k-1,k) (Combinations with repetitions) C(n,k) (Combinations)

27 27 Brainstorm 騎士在旅途中遇見三位美女,其中有天使也有 魔鬼。天使向來只說真話,而魔鬼總是說謊。 三位美女 A,B,C 的對話如下 : A: B 和 C 之中,至少有一位是天使。 B: A 和 C 之中,至少有一位是魔鬼。 C: 我來告訴你正確的道路。 問題:有幾位天使?


Download ppt "1 Chapter 1 Fundamental Principles of Counting Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004."

Similar presentations


Ads by Google