580 likes | 793 Views
D iscrete mathematics. THE BASIC OF COUNTING. N.V. Bilous. KNURE, Software department, Ph. 7021-446, e-mail: belous@kture.Kharkov.ua. Introduction to combinatorics.
E N D
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? • 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. by bus Kiev by bus Kharkov Lvov by plane by train by train
The basic counting principle • If you have to do k tasks and the first task can be done in ways, n1 the n2 second in ways, …, and nk - in kways then all k tasks can be done together in • n1·n2·n3·…·nk • ways.
Basic difinitions • If Мis a finite set, which contains nelements, we shall name it as n-set and to write |М| = n. • The subset АМ, which contains kelements, is named k-subset. • The n-set X is named linearly ordered, if each element x has its own number i {1,2,.., n}.
The sum rule • If a first task can be done in n1ways and a second inn2ways, and if these tasks cannot be done at the same time, then there are • n1 + n2 • to do either task.
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 representative.
The sum rule • We can extend the sum rule to more than two tasks. • Suppose that the tasks T1, T2, …,Tmcan be done in n1, n2, …, 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 • n1+n2+…+nm
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.
The product rule • Suppose that procedure can be broken down into two tasks. If there are n1 ways to do the first task and n2ways to do the second task after the first task has been done, then there are • n1·n2 • ways to do the procedure.
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
The product rule • An extended version of the Product rule • Suppose that a procedure is carried out by performing the tasks. T1, T2, …,Tm.If task T1can be done in n1 ways after tasks T1, T2, …,Ti-1, and have been done, then there are • n1·n2·…·nm • ways to carry out the procedure.
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.
Counting subsets of a finite set • The number of the different subsets of a finite set S is2|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 i-th 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|
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=P6+P7+P8 • By the Product rule:36nthe number of strings of n characters,26n the number of strings with no digits.Hence, • P6=366-266=1867866560 • P7=367-267=70332353920 • P8=368-268=2612282842880 • Consequently, P=P6+P7+P8=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.
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)+1has been used.
The pigeonhole principle • Example • Among 100 people there are at least • [100/12] =9 • who were born in the same month.
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 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 lengthr from a set with n elements. An ordered arrangement by length rof a set is called anr-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).
Permutation • The number ofr-permutationsof 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.
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
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}.
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.
Permutation Ifr = nthen => 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.
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.
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.
Circular permutation • Thus we have 5! unique linear arrangements of the children, but we can group those so each group has 5arrangements that show the children in the same position relative to each other. Therefore, we have 5!/5=4!circular permutations of the five children.
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.
Combinations • Anr-combinationof elements of a set is an unordered selection ofr elements from the set. Thus, anr-combinationis 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
Combinations • The number ofr-combinationsof a set withn distinct elements is denoted by C(n,r) • P(n,r) = C(n,r) • P(r,r)
Combinations • Example • Let Cbe the set {a, b, c, d} • The number of 2-combinations from Cis • Six subsets: {a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}.
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:
Combinations • The number of k-combinations ofelements1,2...,n, which contains anelement 1or does not contain anelement 1(after the sum rule): • C (n, r) = C (n-1, r) + C (n-1, r-1) • Recurrence relation.
Binomial coefficient • Let n and r be nonnegative integers with rn. Then • C(n,r) = C(n, n-r) • This number is also called a binomial coefficient.
The binomial theorem • Let x and ybe variables, and let n be a positive integer
The binomial theorem • Example
The binomial theorem • Example • What is the coefficient of x12y13in the expansion of (x+y)25? • From the Binomial theorem it follows that this coefficient is
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 trianglegeometric arrangement of the binomial coefficients • 2+1=3
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.
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,
Permutations with repetition • The number of different permutations of n objects, where there n1indistinguishable objects of type 1, n2indistinguishable objects of type 2, ..., and nkindistinguishable objects of typek, is
Permutations with repetition • Example • How many different strings can be made by reordering the letters of the wordSUCCESS? • Solution
Permutations with repetition • Example • How many strings of length n can be formed from the English alphabet? • By the Product rule: • 26n • stings of length n.
Permutations with repetition • The number of r-permutations of a set with nobjects with repetition allowed is • (n,r)=P((n),r)=nr
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)
Combinations with repetition • Example • A cookie shop has four different kinds of cookies. How many different ways can six cookies be chosen?
Combinations with repetition • The recurrence formulafor
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.
The principle of inclusion-exclusion • How many positive integers not exceeding 1000 are divisible by 7 or 11? divisible by 7 divisible by 11