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.

Slides:



Advertisements
Similar presentations
Lecture 4 4.1,4.2 Counting. 4.1 Counting Two Important Principles: Product Rule and Sum Rule. Product Rule: Assume we need to perform procedure 1 AND.
Advertisements

Lecture 4 4.1,4.2 Counting. 4.1 Counting Two Important Principles: Product Rule and Sum Rule. Product Rule: Assume we need to perform procedure 1 AND.
Counting Chapter 6 With Question/Answer Animations.
Recursively Defined Functions
The Pigeonhole Principle
Section 4.1: The Basics of Counting As we have seen, one way to count the number of objects in a finite set S is to produce a one-to-one correspondence.
after UCI ICS/Math 6A, Summer Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to.
College of Information Technology & Design
1 Combinatorics Rosen 6 th ed., § , § Combinatorics Count the number of ways to put things together into various combinations.Count the number.
Copyright © Zeph Grunschlag, Counting Techniques Zeph Grunschlag.
1 Section 4.1 Basics of Counting. 2 Basic Counting Principles: Sum Rule Suppose you have two tasks to perform: –The first task can be done in n 1 ways;
CSE115/ENGR160 Discrete Mathematics 04/10/12
Combinations We should use permutation where order matters
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CS100 : Discrete Structures
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Counting Chapter 6 With Question/Answer Animations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Counting. Why counting  Determine the complexity of algorithms To sort n numbers, how many instructions are executed ?  Count the number of objects.
The Basics of Counting Section 6.1.
Counting. Product Rule Example Sum Rule Pigeonhole principle If there are more pigeons than pigeonholes, then there must be at least one pigeonhole.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Basics of Counting Section 6.1.
Section Section Summary The Product Rule The Sum Rule The Subtraction Rule The Division Rule Examples, Examples, and Examples Tree Diagrams.
Module #15: Combinatorics Rosen 5 th ed., §§ & §6.5 Now we are moving on to Ch. 4 It is the study of arrangement of objects e.g. enumeration, counting.
CSNB143 – Discrete Structure
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
CS 103 Discrete Structures Lecture 16
5.2 The Pigeonhole Principle
Discrete Structures Counting (Ch. 6)
Counting.
Chapter 7 – Counting Techniques CSNB 143 Discrete Mathematical Structures.
1 The Pigeonhole Principle CS 202 Epp section 7.3.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Section Basic Counting Principles: The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n 1.
1 The Pigeonhole Principle CS 202 Epp section ??? Aaron Bloomfield.
CS 104: Discrete Mathematics
Pigeonhole Principle – Page 1CPTR311 – Discrete Structures CPTR311 Discrete Structures Pigeonhole Principle Reading: Kolman, Section 3.3.
Discrete Mathematics. Exercises Exercise 1:  There are 18 Computer Science (CS) majors and 325 Business Administration (BA) majors at a college.
Section The Pigeonhole Principle If a flock of 20 pigeons roosts in a set of 19 pigeonholes, one of the pigeonholes must have more than 1 pigeon.
Chapter 6 With Question/Answer Animations Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 5 Counting 歐亞書局.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Example A standard deck of 52 cards has 13 kinds of cards, with four cards of each of kind, one in each of the four suits, hearts, diamonds, spades, and.
Discrete Mathematics Counting.
ICS 253: Discrete Structures I
Chapter 5, Section 5.1 The Basics of Counting
CSNB 143 Discrete Mathematical Structures
Generalized Permutations and Combinations
The Pigeonhole Principle
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
The Pigeonhole Principle
Counting Chapter 6 With Question/Answer Animations
CS 2210 Discrete Structures Counting
Recursively Defined Functions
CS100: Discrete structures
Discrete Structures for Computer Science
Module #15: Combinatorics
The Pigeonhole Principle
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Module #15: Combinatorics
The Pigeonhole Principle
Representations of Integers
Discrete Mathematics and its Applications
Presentation transcript:

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.

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.

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 = = 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.

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 = 2600 different ways that a chair can be labeled.  the largest number of chairs that can be labeled differently is 2600.

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 = = 57

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 Hence,

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.

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.

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 = – 32 = 160

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.

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.

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.

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 = = 9 Minimum 9 cards are to be selected that atleast 3 are of same suit

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.