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

## Presentation on theme: "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."— 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 28 + 36 = 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 20 + 23 + 17 + 31 = 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.