Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction Suppose that a password on a computer system consists of 6, 7, or 8 characters. Each of these characters must be a digit or a letter of the.

Similar presentations


Presentation on theme: "Introduction Suppose that a password on a computer system consists of 6, 7, or 8 characters. Each of these characters must be a digit or a letter of the."— Presentation transcript:

1

2 Introduction Suppose that a password on a computer system consists of 6, 7, or 8 characters. Each of these characters must be a digit or a letter of the alphabet. Each password must contain at least one digit. How many such passwords are there? The techniques needed to answer this question and a wide variety of other counting problems will be solved by using counting principles.

3 Basic Counting Principles Product Rule Suppose that a procedure can be broken down into a sequence of two tasks. If there are n 1 ways to do the first task and for each of these n1 ways, there are n 2 ways to do the second task, then there are n 1 n 2 ways to do the procedure. Ex. A new company with just two employees, Verma and Patel, rents a floor of a building with 12 offices. How many ways are there to assign different offices to these two employees.

4 Sol. Assign an office to Verma, which can be done in 12 ways, then assign an office to Patel different from the office assigned to Verma, which can be done in 11 ways. By the product rule, no. of ways to assign offices to these two employees = 12. 11 = 132 Ex. How many different bit strings of length 7 are there? Sol. Each of the seven bits can be chosen in two ways, either 0 or 1. By the product rule, there are 2 7 = 128 different bit strings of length seven.

5 Ex. The chairs of an auditorium are 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. Assign one of the 26 letters and then assign one of the 100 possible integers to the seat. By product rule, there are 26.100 = 2600 different ways that a chair can be labeled.  the largest number of chairs that can be labeled differently is 2600.

6 Sum Rule If a task can be done either in one of n 1 ways or in one of n 2 ways, where none of the n 1 ways is the same as any of the n 2 ways, then there are n 1 + n 2 ways to do the task. Ex A student can choose a computer project from one of three lists. The three lists contain 23, 15 and 19 possible projects respectively. No project is on more than one list. How many possible projects are there to choose from? Sol A student can choose a project by selecting a project from first list, second list or the third list. Since no project is on more than one list, by the sum rule, no. of ways to choose a project = 23 + 15 + 19 = 57

7 Ex. Each user on a computer system has a password, which is 6 to 8 characters long where each character is an upper case letter or digit. Each password must contain at least one digit. How many possible passwords are there? Sol. Let P 6, P 7, and P 8 denote the number of possible passwords of length 6, 7 and 8, respectively. By sum rule, the total number of possible passwords = P 6 + P 7 + P 8 By the product rule, the number of strings of six characters is 36 6, and the number of strings with no digits is 26 6. Hence,

8 P 6 = 36 6 – 26 6 = 2,176,782,336 – 308,915,776 = 1,867,866,560 P 7 = 36 7 – 26 7 = 78,364,164,096 – 8,031,810,176 = 70,332,353,920 and P 8 = 36 8 – 26 8 = 2,821,109,907,456 – 208,827,064,576 = 2,612,282,842,880 Consequently, P = P 6 + P 7 + P 8 = 2,684,483,063,360. Ex. If there are 14 boys and 12 girls in a class. Find the number of ways of selecting one student as class representative.

9 The Inclusion – Exclusion Principle Suppose that a task can be done in n 1 or in n 2 ways, but that some of the n 1 ways to do the task are the same as some of the n 2 other ways to do the task. In this situation we can not use the sum rule to count the number of ways to do the task. To correctly count the number of ways to do the two tasks, we add the number of ways to do it in one way and the number of ways to do it in the other way, and then subtract the number of ways to do the task in a way that is both among the set of n1 ways and the set of n2 ways. This technique is called the principle of inclusion- exclusion. Also called the subtraction principle.

10 Ex. How many bit strings of length 8 either start with a 1 bit or end with two bits 00. Sol. In first case, the first bit can be chosen in only one way and each of the other seven bits can be chosen in two ways. So, bit string of length 8 that begins with a 1 in 2 7 = 128 ways. Similarly, bit string of length 8 ending with two bits 00, in 2 6 = 64 ways. Now, there are some bit strings which starts with 1 and ends with 00 both, in 2 5 = 32 ways. Hence, the number of bit strings of length 8 that begin with a 1 or end with a 00 = 128 + 64 – 32 = 160

11 The Pigeonhole Principle Suppose that a flock of 20 pigeons fly into a set of 19 pigeonholes to roost. Because there are 20 pigeons but only 19 pigeonholes, at least one of these 19 pigeonholes must have at least 2 pigeons in it. Theorem 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 of the objects. This is also called Dirichlet drawer principle.

12

13 Ex. Among any group of 367 people, there must be at least two with the same birthday, because there are only 366 possible birthdays. Ex. In any group of 27 English words, there must be at least two that begin with the same letter, because there are 26 letters in the English alphabets.

14 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. Then total number of objects is at most [ ∵  N/k  < (N/k) + 1 ] This is a contradiction because there are a total of N objects.

15 Ex. Among 100 people there are at least  100/12  = 9 who were born in the same month. Ex. a) 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? Sol. Let number of cards to be selected = N Since number of suits = 4 By the generalized pigeonhole principle, there is at least  N/4  cards of one suit If at least three cards of one suit are to be selected, then  N/4   3 N = 2. 4 + 1 = 9 Minimum 9 cards are to be selected that atleast 3 are of same suit

16 b) How many cards must be selected to guarantee that at least three hearts are selected? Sol. In worst case, we can select all the clubs, diamonds, and spades, 39 cards in all, before we select a single heart. The next three cards will be all hearts, so we may need to select 42 cards to get 3 hearts.


Download ppt "Introduction Suppose that a password on a computer system consists of 6, 7, or 8 characters. Each of these characters must be a digit or a letter of the."

Similar presentations


Ads by Google