Discrete mathematics THE BASIC OF COUNTING N V
Discrete mathematics THE BASIC OF COUNTING N. V. Bilous KNURE, Software department, Ph. 7021 -446, e-mail: belous@kture. Kharkov. ua
Introduction to combinatorics From Kharkov to Kiev you can go by bus, by train, and by plane. From Kiev to Lvov you can go by bus and by train. How many variants are there to travel from Kharkov to Lvov? Kharkov by bus by plane by train Kiev by bus Lvov by train Solution: 3 • 2=6 Choosing each of 3 variants to travel from Kharkov to Kiev you can choose 2 variants to travel from Kiev to Lvov. 2
The basic counting principle If you have to do k tasks and the first task can be done in ways, n 1 the n 2 second in ways, …, and nk - in k ways then all k tasks can be done together in n 1·n 2·n 3·…·nk ways. 3
Basic difinitions If М is a finite set, which contains n elements, we shall name it as n-set and to write |М| = n. The subset А М, which contains k elements, is named k-subset The n-set X is named linearly ordered, ordered if each element x has its own number i {1, 2, . . , n}. 4
The sum rule If a first task can be done in n 1 ways and a second in n 2 ways, and if these tasks cannot be done at the same time, then there are n 1 + n 2 to do either task. 5
The sum rule Example Suppose that either a member of the mathematics faculty or a student who is a mathematics major 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 mathematics faculty and 83 mathematics majors? The first task choosing a member of the mathematics faculty can be done in 37 ways. The second – in 83 ways. So there are 37+83=120 possible ways to pick this 6 representative.
The sum rule We can extend the sum rule to more than two tasks. Suppose that the tasks T 1, T 2, …, Tm can be done in n 1, n 2, …, nm ways, respectively, and no two of this tasks can be done at the same time. Then the number of ways to do one of these tasks is n 1+n 2+…+nm 7
The sum rule Example A student can choose a computer project from one of three lists. The three lists contain 23, 15, and 19 possible projects, respectively. Ho many possible projects are there to choose from? There are 23+15+19=57 projects to choose from. 8
The product rule Suppose that 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. 9
The product rule Example There are 32 microcomputers in a computer center. Each microcomputer has 24 ports. How many different ports to microcomputer are there in the computer center? There are two tasks: first picking a microcomputer and then picking a port on this microcomputer. After the Product rule the quantity of different ports to a microcomputer in the center is: 32· 24 = 768 10
The product rule An extended version of the Product rule Suppose that a procedure is carried out by performing the tasks. T 1, T 2, …, Tm. If task T 1 can be done in n 1 ways after tasks T 1, T 2, …, Ti-1, and have been done, then there are n 1·n 2·…·nm ways to carry out the procedure. 11
The product rule Example How many different bit strings are there of length seven? Each of the seven bits can be chosen in two ways, since beach bit is either zero or one. So there are: 27=128 different bit strings of length seven. 12
Counting subsets of a finite set The number of the different subsets of a finite set S is 2|S| Proof: Let S be a finite set. List the elements of S in arbitrary order. Recall that there is one-to-one correspondence between subsets of S and bit strings of length |S|. Namely, a subset of S is associated with the bit string with a 1 in the ith position if the i-th element in the list is in the subset, and a 0 in this position otherwise. By the Product rule, there are 2|S| bit strings of length |S|. |P(S)|= 2|S| 13
The product rule Example Each user on a computer system has a password, which is six to eight 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? Let P be he total number of possible passwords. By the Sum rule: P=P 6+P 7+P 8 By the Product rule: 36 n the number of strings of n characters, 26 n the number of strings with no digits. Hence, P 6=366 -266=1867866560 P 7=367 -267=70332353920 P 8=368 -268=2612282842880 14 Consequently, P=P 6+P 7+P 8=2684483063360.
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. There are more Pigeons than Pigeonholes. 15
The generalized pigeonhole principle If n objects are placed into k boxes, then there is at least one box containing at least n/k objects. Proof: Suppose that none of the boxes contains more than [N/k]– 1 objects. The total number of objects is at most k([n/k]-1)<k(((n/k)+1)-1)=n where the inequality [n/k]<(n/k)+1 has been used. 16
The pigeonhole principle Example Among 100 people there at least [100/12] =9 who were born in the same month. 17
The pigeonhole principle Example What is the minimum number of students required in a discrete mathematics class to be sure that at least six will receive the same grade, if there are five possible grades A, B, C, D, and F? The minimum number of students needed to guarantee that at least six students receive the same grade is the smallest integer N such that [N/5]=6. The smallest such integer is N=5· 5+1=26. 26 is the minimum number of students needed to be sure 18 that at least six students receive the same grade.
Permutation A permutation of a set of n distinct elements is an ordered arrangement of these elements. We also are interested in ordered arrangements by length r from a set with n elements. An ordered arrangement by length r of a set is called an r-permutation Example М = {1, 2, 3}. 2–permutation (1, 2); (2, 1); (1, 3); (3, 1); (2, 3); (3, 2); 3–permutation (1, 2, 3); (1, 3, 2); (2, 1, 3); (2, 3, 1); (3, 1, 2); (3, 2, 1). 19
Permutation The number of r-permutations of a set with n distinct elements is Proof: The first element of the permutation can be chosen in n ways, since there are n elements in the set, there are (n 1) ways to choose the second element (n-2)-choosing the third, …, and until there exactly n-r+1 ways to choose the r-th element. Using Product rule, there are n (n-1)·(n-2)·…·(n-r+1) r-permutations of the set. 20
Factorial notation A compact representation for the multiplication of consecutive integers. We use n! to represent the product n·(n-1)·(n-2)·. . . ·(2)·(1) where n is some positive integer. 0!=1 21
Permutation Example Almost every morning or evening on the news I hear about the State of Illinois DCFS, the Department of Children and Family Services. I'm confused! How many different 4 -letter ordered arrangements, or permutations, exist for the set of letters {D, F, S, C}? Thinking of four positions to fill, __ __ , we have 4 letters to choose from for the first position, 3 for the next, 2 letters for the next position, and 1 choice for the last position. Using the multiplication principle, there are 4· 3· 2· 1=24 different 4 -letter ordered arrangements for the set of letters {D, F, S, C}. 22
Permutation Example How many different ways are there to select 4 different players from 10 players on a team to play four tennis matches, where the matches are ordered? The number of 4 -permutations of a set with 10 elements is P(10, 4)=10· 9· 8· 7=5040. 23
Permutation If r = n then => P(n, n) = n! Example A saleswomen has to visit seven different cities. She must begin her trip in a specified city, but she can visit the other seven cities in any order she wishes. How many possible orders can she use when visiting these cities? The number of possible paths between the cities is the number of permutations of seven elements. Consequently, there are 7!=7· 6· 5· 4· 3· 2· 1= 5040 ways for saleswomen to choose her tour. 24
Circular permutation How many ways are there to arrange 5 children at a square and at a round table? If we consider the case when children sit at a square table: After the formula of the n-permutation we have P(5, 5) = 5! arrangements. 25
Circular permutation Now imagine that these children sit at a circular table : In each of these cases, the same people are sitting next to each other. Although there has been a change— a rotation – about the table, the five children are still in the same positions relative to each other. 26
Circular permutation Thus we have 5! unique linear arrangements of the children, but we can group those so each group has 5 arrangements that show the children in the same position relative to each other. Therefore, we have 5!/5=4! circular permutations of the five children. 27
Circular permutation A circular permutation is a circular arrangement of elements for which the order of the elements must be taken into account. In general: For n elements, there are (n-1)! circular permutations. The number of circular permutations of r-elements taken from an n-element set is P(n, r)/r. 28
Combinations An r-combination of elements of a set is an unordered selection of r elements from the set. Thus, an rcombination is simply a subset of the set with r elements. Example Let S be the set {1, 2, 3, 4}. Then {1, 3, 4} is a 3 -combination from S 29
Combinations The number of r-combinations of a set with n distinct elements is denoted by C(n, r) P(n, r) = C(n, r) • P(r, r) 30
Combinations Example Let C be the set {a, b, c, d} The number of 2 -combinations from C is Six subsets: {a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}. 31
Combinations Example The committee which develops a discrete mathematics course is to consist of 3 faculty members from the mathematics department and 4 from the computer science department. There are 9 faculty members from the mathematics department and 11 from the computer science department. How many ways are there to select it? After the Product rule: 32
Combinations The number of k-combinations of elements 1, 2. . . , n, which contains an element 1 or does not contain an element 1(after the sum rule): C (n, r) = C (n-1, r) + C (n-1, r-1) Recurrence relation 33
Binomial coefficient Let n and r be nonnegative integers with r n. Then C(n, r) = C(n, n-r) This number is also called a binomial coefficient. 34
The binomial theorem Let x and y be variables, and let n be a positive integer 35
The binomial theorem Example 36
The binomial theorem Example What is the coefficient of x 12 y 13 in the expansion of (x+y)25? From the Binomial theorem it follows that this coefficient is 37
Pascal`s triangle Pascal`s identity: Let n and k be positive integers then C(n+1, k)=C(n, k-1)+C(n, k) Pascal`s triangle geometric arrangement of the binomial coefficients 2+1=3 38
Pascal’s identity Combinations of 8 out of 20 that do not include 20 are simply the combinations of 8 out of 19, so there are C(19, 8). Consider the combinations of 8 in 20 that include 20. Since all these combinations include 20, the only variation comes from the 7 other objects chosen, so there are C(19, 7). Therefore C(20, 8)=C(19, 8)+C(19, 7) and, in general C(n, r) = C(n-1, r) + C(n-1, r-1) which is known as Pascal's identity. 39
Combinations Let n be a possible integer. Then A set with n elements has a total of different subsets. Each subset has either zero elements, one element, …, or n elements in it. There are C(n, 0) subsets with zero elements, C(n, 1) subsets with one element, …, and С(n, n) subsets with n elements. Hence, 40
Permutations with repetition The number of different permutations of n objects, where there n 1 indistinguishable objects of type 1, n 2 indistinguishable objects of type 2, . . . , and nk indistinguishable objects of type k, is 41
Permutations with repetition Example How many different strings can be made by reordering the letters of the word SUCCESS ? Solution 42
Permutations with repetition Example How many strings of length n can be formed from the English alphabet? By the Product rule: 26 n stings of length n. 43
Permutations with repetition The number of r-permutations of a set with n objects with repetition allowed is (n, r)=P((n), r)=nr 44
Combinations with repetition There are C(n+r– 1, r) r-combinations from a set with n elements when repetition of elements is allowed. C(n, r)=C(n+r-1, r) 45
Combinations with repetition Example How many different ways can six cookies be chosen? 46
Combinations with repetition The recurrence formula for 47
Combinations and permutations with and without repetition Type Repetition Allowed? R-permutations No R-combinations NO R-permutations Yes R-combinations Yes Formula nr 48
The principle of inclusion-exclusion Example There are 10 spectators at a ball game and 4 are wearing caps. How many spectators are not wearing caps? Straightforward subtraction yields the result: 10 -4=6. There are 6 spectators not wearing caps We have: |T|=10 – the number of all spectators |C|=4 – the property "wearing a cap" So ~C is the property "not wearing a cap. " This gives us |~C|=|T|-|C|=10 -4=6. 49
The principle of inclusion-exclusion How many positive integers not exceeding 1000 are divisible by 7 or 11? divisible by 7 divisible by 11 50
The principle of inclusion-exclusion Let A 1, A 2, …, An be finite sets. 51
The principle of inclusion-exclusion A total of 1232 students have taken a course in Spanish, 879 -in French, and 114 -in Russian. Further, 103 have taken courses in both Spanish and French, 23 -in both Spanish and Russian and 14 -in both French and Russian. If 2092 students have taken at least one of Spanish, French, Russian how many students have taken a course in all three languages? Solution There are seven students who have taken courses in Spanish, 52 French, and Russian.
Discrete probability The probability of an event E, which is a subset of a finite sample space S of equally likely outcomes, is P(E)=|E|/|S| 53
Discrete probability Example An urn contains four blue balls and five red balls. What is the probability that a ball chosen from the urn is blue? 9 - possible outcomes 4 - possible outcomes produce blue ball The probability that blue ball is chosen is 4/9. 54
Discrete probability There are many lotteries now that award enormous prizes to people who correctly choose a set of six numbers out of the first n positive integers, where n is usually between 30 and 50. What is the probability that a person picks the correct six numbers out of 40? There is only one winning combination. The total number of ways to choose six numbers out of 40 is So the probability of picking the winning ombination is . 55
- Slides: 55