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.

Slides:



Advertisements
Similar presentations
Basic Counting Rosen 4.1. Sum Rule If a first task can be done in n 1 ways and a second task can be done in n 2 ways, and if these tasks cannot be done.
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.
1 More Counting by Mapping Lecture 16: Nov 7. 2 This Lecture Division rule Catalan number.
Recursively Defined Functions
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.
Section 7.4: Closures of Relations Let R be a relation on a set A. We have talked about 6 properties that a relation on a set may or may not possess: reflexive,
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.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
How many ways are there to pass through city A where the arrows represent one-way streets? Answer: mn ways The counting principal: Suppose two experiments.
Advanced Counting Techniques
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.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Counting Chapter 6 With Question/Answer Animations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
MAT 2720 Discrete Mathematics Section 6.1 Basic Counting Principles
1 Permutations and Combinations. 2 In this section, techniques will be introduced for counting the unordered selections of distinct objects and the ordered.
Introduction to Counting Discrete Structures. A Multiplication Principle.
The Basics of Counting Section 6.1.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
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.
1 Lecture 4 (part 1) Combinatorics Reading: Epp Chp 6.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Sullivan Algebra and Trigonometry: Section 14.2 Objectives of this Section Solve Counting Problems Using the Multiplication Principle Solve Counting Problems.
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.
Counting Techniques and Some Other Math Team Strategies Susan Schwartz Wildstrom Walt Whitman High School Bethesda, MD NCTM National Meeting April 6, 2001.
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.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
Counting Techniques. L172 Agenda Section 4.1: Counting Basics Sum Rule Product Rule Inclusion-Exclusion.
CS 103 Discrete Structures Lecture 16
1 Basics of Counting CS/APMA 202 Rosen section 4.1 Aaron Bloomfield.
Discrete Structures Counting (Ch. 6)
1 Section 6.5 Inclusion/Exclusion. 2 Finding the number of elements in the union of 2 sets From set theory, we know that the number of elements in the.
Introduction to Discrete Probability Epp, section 6.x CS 202.
Counting Principles Multiplication rule Permutations Combinations.
Section 3.2: Sequences and Summations. Def: A sequence is a function from a subset of the set of integers (usually the set of natural numbers) to a set.
Chapter 7 – Counting Techniques CSNB 143 Discrete Mathematical Structures.
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.
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.
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.
CS 104: Discrete Mathematics
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.
Section 10.1 and Hand Back Exam #3 The class average was much better on this exam (no adjustments necessary). Activity 0: –Discuss problems 2 and.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
CS336 F07 Counting 2. Example Consider integers in the set {1, 2, 3, …, 1000}. How many are divisible by either 4 or 10?
Discrete Mathematics Counting.
ICS 253: Discrete Structures I
Chapter 5, Section 5.1 The Basics of Counting
The Pigeonhole Principle
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
Counting Chapter 6 With Question/Answer Animations
Recursively Defined Functions
One, two, three, we’re… Counting.
CS100: Discrete structures
Discrete Structures for Computer Science
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Representations of Integers
Copyright © Zeph Grunschlag,
Presentation transcript:

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 from the set S to the set {1, 2, 3, …, n}. This shows that there are n distinct elements in the set S. While this is a feasible approach for sets with small cardinality, we do not wish to enumerate all of the elements in a set with large cardinality. We will now introduce techniques that will allow us to count the number of objects in a set without having to enumerate all of the objects.

The Product Rule: Suppose that a procedure can be broken down into a sequence of two tasks that must be done in succession in order to complete the procedure. 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 completed, then there are n 1 * n 2 ways to complete the procedure. Ex: The chairs of an auditorium are to be labeled with a capital letter and a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently under this scheme? Examples of labels using this scheme are A29, D100, C1, etc. We can think of the procedure of choosing a label for a chair as two successive tasks: We first choose a letter, then we choose a positive integer not exceeding 100. Determining how many chairs can be labeled differently under this scheme is equivalent to determining how many different ways there are of completing this procedure. By the product rule, there are 26 * 100 = 2600 different labels. Note that to choose a label we must complete both tasks [product rule].

The Generalized Product Rule: If a procedure can be broken down into a sequence of m tasks that must be done in succession in order to complete the procedure and if there are n 1 ways to do the first task and n 2 ways to do the second task after the first has been completed, and n 3 ways to do the third task after the first two have been completed, …, then there are n 1 * n 2 * … * n m ways to complete the procedure. Ex: How many different bit strings are there of length 9? We already know that the answer is 2 9. However, we can verify this by applying the product rule. Consider that to choose a bit string of length 9, we must choose the first bit, then choose the second bit, …, and finally choose the ninth bit. There are nine tasks to perform in succession and each of them can be done in 2 ways (choose a 0 or a 1). So by the product rule, there are 2*2*2*2*2*2*2*2*2 = 2 9 ways to choose a bit string of length 9.

Ex: How many different license plates can be made if each plate must have 3 capital letters followed by 4 digits? Ex: How many different functions are there from a set with m elements to a set with n elements. Recall that the requirement for a map to be a function is that each of the m elements in the domain is mapped to exactly one of the n elements of the range. Hence we have m tasks to perform (choosing an element of the range to map to for each of the m elements) and n ways to perform each task (n choices for where to map each element to). So by the product rule, there are n*n*…*n = n m ways to construct a function from a set with m elements to a set with n elements. We have 7 task to complete in succession and the product rule tells us that there are 26*26*26*10*10*10*10 = 26 3 *10 4 different plates. Note that in this problem each plate is required to have exactly 7 chars.

Ex: How many different one-to-one functions are there from a set with m elements to a set with n elements. Before we proceed to try to count the functions, recall that if m > n then there are no one-to-one functions, so the answer is 0 in this case. If m  n then we have m tasks to perform in succession in order to construct a one-to-one function. For the ‘first’ element in the domain, we have n elements of the codomain to which we can map. For the ‘second’ element in the domain, we have n – 1 elements of the codomain to which we can map, …, for the ‘mth’ element in the domain, we have n – (m – 1) elements of the codomain to which we can map. So the product rule tells us that there are n*(n – 1) * … * (n – (m – 1)) = n!/(n – m)! ways to construct a one-to-one function from a set with m elements to a set with n elements if m  n (and 0 ways if m > n).

The Sum Rule: Suppose that a procedure can be completed by either performing one task or another task. If there are n 1 ways to do one of the tasks and n 2 ways to do the other task and if these tasks can not be done at the same time, then there are n 1 + n 2 ways to complete the procedure. Ex: Suppose that we need to appoint a member of a committee and this member must be either a mathematics professor or a computer science professor. If there are 28 mathematics professors and 36 computer science professors (and there are no joint appointments) then how many choices do we have for the committee member? We can complete the procedure of appointing a committee member by either choosing a mathematics professor or choosing a computer science professor. And since there are no joint appointments, then the sum rule tells us that there are = 64 different ways to select the committee member.

The Generalized Sum Rule: If a procedure can be completed by performing one of m tasks and if there are n 1 ways to do the first task and n 2 ways to do the second task, …, and n m ways to do the mth task and no two of the tasks can be done at the same time, then there are n 1 + n 2 + … + n m ways to complete the procedure. Ex: A college requirement can be filled by taking a course in History, Economics, Sociology, or Psychology. If there are 20 History courses, 23 Economics courses, 17 Sociology courses, and 31 Psychology courses (none of which are cross-listed) offered this semester, how many different ways are there to fulfill the requirement this semester? The generalized sum rule tells us that there are = 91 ways to fulfill the requirement this semester. Sometimes we will need to use the product rule and sum rule in tandem to solve a counting problem.

Ex: A password is required to have 6 to 8 characters, each of which is an uppercase letter, lowercase letter, or a digit. How many valid passwords are there? The procedure of choosing a valid password can be completed by performing one of 3 tasks, P 6, P 7, or P 8, where P i is the task of choosing a password of length i. Clearly no two of these tasks can be performed at the same time, so the sum rule tells us that the procedure of choosing a password can be done in P 6 + P 7 + P 8 ways. Similarly, when we choose each character in a password, the sum rule tells us that there are = 62 ways to choose each character. Then by the product rule, there are 62 6 ways to complete P 6, 62 7 ways to complete P 7, and 62 8 ways to complete P 8. So there are ways to choose a valid password under the given constraints. That is, there are 221,918,520,426,688 different valid passwords.

Ex: What if we require our passwords to have at least 1 digit in them? We just found that the total number of passwords that satisfy our original criteria was 221,918,520,426,688. If we now require that for a password to be valid it must contain at least 1 digit, then some of the passwords in the above count are not valid (namely those with no digits in them). So if we count the number of the above passwords that have no digits, then we can subtract this from the total above to leave us with a count of the number of passwords that satisfy our original criteria and contain at least 1 digit. Once again the sum rule tells us that there are N 6 + N 7 + N 8 ways to choose a password with no digits if N i is the number of ways to choose a password of length i with no digits. Then the sum rule tells us there are = 52 ways to choose each character in one of these passwords. So by the product rule there are ways to choose a password with no digits. Subtracting, there are 167,410,949,583,040 valid passwords left.

The Principle of Inclusion-Exclusion One of the requirements for the sum rule is that the tasks to be done can’t be done at the same time. When two tasks can be done at the same time, if we simply add the number of ways to do each task then we over count the number of ways to complete the procedure because some ways are counted in more than one task. To correct for this over counting, we introduce the principle of inclusion-exclusion. Ex: If we must appoint a committee representative with the requirement that the representative is a math major or a CS major, how many ways are there to appoint this representative? If we try to apply the sum rule and simply add the number of math majors and the number of CS majors, then we will only get the correct answer if there are no students majoring in both math and CS. To correct for this, we must simply subtract out the number of students majoring in both math and CS.

The Principle of Inclusion-Exclusion: Suppose that a procedure can be completed by either performing one task or another task. If there are n 1 ways to do one of the tasks and n 2 ways to do the other task and if there are m ways to do both tasks at the same time, then there are n 1 + n 2 – m ways to complete the procedure. Ex: How many bit strings of length 8 either start with a 1 bit or end with two 0 bits? We can complete the procedure of selecting an appropriate bit string by either choosing a bit string of length 8 that starts with a 1 bit or choosing a bit string of length 8 that ends with two 0 bits. However, it is possible to do both tasks at once, so we must subtract out the number of ways to choose a bit string of length 8 that starts with a 1 bit and ends with two 0 bits. There are 2 7 bit strings of length 8 that start with a 1 bit (choose the last 7 bits), 2 6 bit strings of length 8 that end with two 0 bits (choose the first 6 bits), and 2 5 bit strings of length 8 that start with a 1 bit and end with two 0 bits. So there are – 2 5 = 160 desired bit strings.