Presentation is loading. Please wait.

Presentation is loading. Please wait.

Counting.

Similar presentations


Presentation on theme: "Counting."— Presentation transcript:

1 Counting

2 The Basics of Counting Basic counting principle: product rule and sum rule The product rule: Suppose that a procedure can be broken down into a sequence of two tasks. If there are n1 ways to do the first task and for each of these ways of doing the first task, there are n2 ways to do the second task, then there are n1n2 ways to do the procedure.

3 Example: A new company with just two employees, Sanchez and Patel, rents a floor of a building with 12 offices. How many ways are there to assign different offices to these two employees? Solution. 12*11=132

4 Example: The chairs of an auditorium are to be labeled with a letter and a positive integer not exceeding What is the largest number of chairs that can be labeled differently? 26*100

5 Example: There are 32 microcomputers in a computer center
Example: There are 32 microcomputers in a computer center. Each microcomputer has 24 ports. How many different port to a microcomputer in the center are there? 32*24

6 Example: How many different bit strings of length 7 are there?
27 Example: How many different license plates are available if each plate contains a sequences of three letters followed by three digits? 263103

7 Example: How many functions are there from a set with m elements to a set with n elements?
nm Example: How one-to-one functions are there from a set with m elements to a set with n elements? Note m>n. n(n-1)…(n-m+1)

8 Example: What is the value of k after the following code has been executed?
for i1:=1 to n1 for i2:=1 to n2 . for im :=1 to nm k:= k+1 Solution: n1n2…nm

9 Example: Using the product rule to show that the number of different subsets of a finite set S is 2|S|.

10 The sum rule: If a task can be done either in one of n1 ways or in one of n2 ways, where none of n1 ways is the same as any one of the set of n2 ways, then there are n1+n2 ways to do this task.

11 Example: Suppose that either a member of the mathematics faculty or a student who is a mathematics majored is chosen as a representative to a university committee. How many different choices are there for this representative if there are 37 members of mathematics faculty and 83 mathematics majors and no one is both a faculty member and a student? Solution: =120

12 Example: A student can choose a computer project from one of three lists. The three lists contain 23, 15, and 19 possible projects, respectively. No projects is on more than one list. How many possible projects are there to choose from? Solution: =57

13 Example: What is the value of k after the following code has been executed?
for i1:=1 to n1 k:= k+1 for i2:=1 to n2 . for im :=1 to nm Solution: n1+n2+…+nm

14 More complex counting problems
Example: In a version of the computer language BASIC, the name of a variable is a string of one or two alphanumeric characters, where uppercase and lowercase 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? V1=26 V2=26*36-5=931 Total=26+931=957

15 Example: Each user on a computer system has password, which is a six to eight character 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? P6= P7= P8= P=P6+P7+P8.

16 The Inclusion-Exclusion Principle
Example: How many bit strings of length eight either start with a 1 bit or ended with two bits 00? =160 |A1A2|=|A1|+|A2|-|A1A2|

17 Example: A Computer company receives 350 applicants from computer graduates for a job planning a line of new Web servers. Suppose that 220 of these people majored in computer science, 147 majored in business, and 51 majored both in in computer science and in business. How many of these applicant majored neither in in computer science nor in business. =316 =34

18 Tree Diagrams Example: How many bit string of length four do not have two consecutive 1s? 1 1 1 1 1 1 1 1 Answer: 8

19 Example: A playoff between two terms consists of at most five games
Example: A playoff between two terms consists of at most five games. The first term that wins three games wins the playoff. In how many different ways can the playoff occur? 2 Game 1 1 1 2 Game2 2 1 1 2 2 2 2 Game 3 1 2 2 2 1 Game 4 2 1 2 1 1 2 20 different ways Game 5 2 1 2 1 2 1 2 1 2 1 2 1

20 Example: Suppose that “I Love New Jersey” T-shirt come in five different sizes, S, M, L, XL, and XXL. Further suppose that each size comes in four colors, white, red, green, and black, except for XL, which comes only in red, green, and black, and in XXL, which comes only in green and black. How many different shirts does a souvenir shop have to stock to have at least one of each available size and color of the T-shirt.

21 5.2 The Pigeonhole Principle
Theorem: (The Pigeonhole Principle) If k is a positive integer and k+1 or more objects are placed into k boxes, then there is at least one box containing two or more objects. Or known as Dirichet drawer principle Corollary: A function f from a set with k+1 or more elements to a set with k elements is not one-to-one.

22 Example: Among any group of 367 people, there must be at least two with the same birthday.
Example: In any group of 27 English words, there must be at least two that begin with the same letter. Example: How many students must be in a class to guarantee that at least two students receive the same score on the final exam, if the exam is graded on a scale from 0 to 100 points. Solution: 102 Example: Show that for every integer n there is a multiple of n that has only 0’s and 1’s in its decimal expansion. (interesting problem)

23 The generalized Pigeonhole Principle
Theorem. (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. Example: Among 100 people there are at least 100/12 =9 who were born in the same month. Example: How many cards must be selected from a standard deck of 52 cards to guarantee that at least three cards of the same suit are chosen? How many must be selected to guarantee that at least three hearts are selected. Solution: 9, 42

24 Example: What is the least number of area codes needed to guarantee that the 25 million phones in a state can assigned to distinct 10-digit telephone? (Assume that the telephone numbers are of the form NXX-NXX-XXXX, where the first three digits form the area code, N represents a digit from 2 to 9 inclusive, and X represents any digit. Solution:  / =4

25 Example: Suppose that a computer science laboratory has 15 workstations and 10 servers. A cable can be used to directly connect a workstation to a server. For each server, only one direct connection to that server can be active at any time. We want to guarantee that at any time any set of 10 or fewer workstations can simultaneously access different servers via direct connections. Although we could do this by every workstation directly to every server using 150 connections, what is the minimum number of direct connections needed to achieve this goal? Solution: 60

26 Some Elegant Applications of Pigeonhole Principle
Example: During a month with 30 days, a baseball team plays at least one 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 term must play exactly 14 days. 1a1<a2<…<a30 45, i<j such that aj=ai+14 |{a1,a2,…,a30} {a1+14,a2+14,…,a30+14}| 59 Thus, i<j such that aj=ai+14

27 Theorem: Every sequence of n2+1 distinct real numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. Example: The sequence 8,11,9,1,4,6,12,10,5,7 contains 10 terms. There are four increasing subsequence of length four, namely, 1,4,6,12; 1,4,6,7; 1,4,6,10, and 1,4,5,7. There is also a decreasing subsequence of length four, namely, 11,9,6,5.

28 Example: Assume that in a group of six people; each pair of individuals consists of two friends or two enemies. Show that there are either three mutual friends or three mutual enemies in the group.

29 5.3 Permutations and Combinations
Example: In how many ways can we select three students from a group of five students to stand in line for a picture? In how many ways we can arrange all five of these students in a line for a picture. Solution: 5*4*3=60, 5*4*3*2*1=120. 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: Let S={1,2,3}. The order arrangement 3,1,2 is a permutation. The ordered arrangement 3,2 is a 2-permutation.

30 Theorem: If n is a positive integer and r is an integer with 1rn, then there are
P(n,r)=n(n-1)(n-2)…(n-r+1) r-permutations of a set with n distinct elements. Corollary. If n and r are integers with 0 rn, then P(n,r)=n!/(n-r)!.

31 Example: How many 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? P(100,3) Example: Suppose that there are eight runners in a race. The winner receives a gold medal, the second-place finisher receives a silver medal, and the third-place finisher receives a bronze medal. How many different ways are there to award these medals, if all possible outcomes of the race can occur and there are no ties. P(8,3)

32 Example: Suppose that a saleswoman has to visit eight different cities
Example: Suppose that a saleswoman has to visit eight 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 the saleswoman use when visiting these cities? 7! Example: How many permutations of the letters ABCDEFGH contain the string ABC? 6!

33 Combinations Example: How many different committees of three students formed from a group of four students? Solution. 4 An r-combination of elements of a set is an unordered selection of r elements from a set. Thus, an r-combination is simply a subset of the set with r-elements. Example: Let S={1,2,3,4}. Then {1,3,4} is a 3-combination from S.

34 The number of r-combinations of a set with n distinct elements is denoted by C(n,r).
Example: Check that C(4,2)=6. Theorem:

35 Example: How many poker hands of five cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards. Corollary. Let n and r are nonnegative integers with rn. Then C(n,r)=C(n,n-r). A combinatorial proof of an identity is a proof that uses counting arguments to proof that both sides of an identity count the same object but in different way. Example: (above)

36 Example: How many ways are there to select five players from a 10-member tennis team to make a trip to a match at another school? C(10,5) Example: A group of 30 people have been trained as astronauts to go on the first mission to Mars. How many different ways are there to select a crew of six people to go to the mission? C(30,6)

37 Example: How many bit strings of length n contains exactly r 1s?
Example: Suppose that there are 9 faculty members in the mathematics department and 11 in the computer science department. How many ways are there to select a committee to develop a discrete mathematics course at a school if the committee is to consist of three faculty members from the mathematics departments and four from the computer Science department?

38 5.4 Binomial Theorem

39

40

41 Some Other Identity of Binomial Coefficients

42 0011001 …………………………..0 of length n+1
with r+1 1’s

43 Generalized Permutations and Combinations
Permutations with repetition Example: How many strings of length r can be formed from the English alphabet? Solution: 26r Theorem: The number of r-permutations of a set of n with repetition allowed is nr.

44 Combinations with repetition
Example: How many ways are there to select four fruit from a bowl containing apples, oranges, and pears if the order in which the pieces are selected does not matter, only the type of fruit and not the individual piece matters, and there are at least four pieces of each type of fruit in the bowl? Example: 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? Assume that the order in which the bills are chosen does not matter, that the bills of each denomination are indistinguishable, and that there are at least fill bills of each type.

45 Theorem. There are C(n+r-1,r)=C(n+r-1,n-1) r-combinations from a set of n elements when repetition of elements is allowed. Example: Suppose that a cookie shop has four different kind of cookies. How many different ways can six cookies be chosen? Assume that only the type of cookie, and not the individual cookies or the order in which they are chosen, matters.

46 Example: How many solutions of the equation x1+x2+x3=11 have, where x1, x2, and x3 are non-negative integers? How many solutions of the equation x1+x2+x3=11 have, where x1, x2, and x3 are integers with x1 1, x2 2, and x3 3?

47 Example: What is the value k after the following pseudocode has been executes?
for i1:=1 to n for i2:=1 to i1 . for im:=1 to im-1 k:=k+1 1im im-1 … i1 n Select m integers from {1,2,…,m} with repetition allowed. k=C(n+m-1,m)

48 Permutations with Indistinguishable Objects
Example: How many different strings can be made by reordering the letters of the word SUCCESS? Theorem: The number of different permutations of n objects, where n1 indistinguishable objects of type 1, n2 indistinguishable objects of type 1, …, and nk indistinguishable objects of type k is

49 Distributing Objects into Boxes
Distinguishable Objects and Distinguishable Boxes How many ways are there to distribute 5 cards to each four players from the standard deck of 52 cards. Theorem: The number of ways to distribute n distinguishable objects into k distinguishable boxes so that ni objects are placed into box i, i=1,2,…,k, equals

50 Distinguishable Objects and Distinguishable Boxes
Example: How many ways are there to place 10 indistinguishable balls into eight distinguishable bins? x1+x2+…+x8=10 C(8+10-1,10)=C(17,10).

51 Distinguishable Objects and Indistinguishable Boxes
Example: How many ways are there to put four different employees into three indistinguishable offices, when each office can contain any number of employees?

52 Let S(n,j) denote the number of ways to distribute n distinguishable objects into j indistinguishable boxes so that no box is empty. The number of S(n,j) is called Stirling number of the second kind.

53 Indistinguishable Objects and Indistinguishable Boxes
How many ways are there to pack six copies of the same book into four identical boxes, where a box can contains as many as six books? 6 5,1 4,2 4,1,1 3,3 3,2,1 3,1,1,1 2,2,2 2,2,1,1

54 If a1+a2+…+aj=n, where a1,a2,…,aj are positive integers with a1a2  …  aj, we say that a1,a2,…,aj is a partition of the positive integer n into j positive integers. If Pk(n) denote the number of partitions of n into at most k integers, then there are pk(n) ways to distribute n indistinguishable objects into k indistinguishable boxes. No simple closed formula exists for this number.

55 5.6 Generating Permutations and Combinations
Omitted.


Download ppt "Counting."

Similar presentations


Ads by Google