1 / 11

Section 4.1: The Basics of Counting

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.

Télécharger la présentation

Section 4.1: The Basics of Counting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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 n1 ways to do the first task and n2 ways to do the second task after the first task has been completed, then there are n1 *n2 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].

  3. 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 n1 ways to do the first task and n2 ways to do the second task after the first has been completed, and n3 ways to do the third task after the first two have been completed, …, then there are n1 *n2 * … * nm ways to complete the procedure. Ex: How many different bit strings are there of length 9? We already know that the answer is 29. 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 = 29 ways to choose a bit string of length 9.

  4. Ex: How many different license plates can be made if each plate must have 3 capital letters followed by 4 digits? We have 7 task to complete in succession and the product rule tells us that there are 26*26*26*10*10*10*10 = 263*104 different plates. Note that in this problem each plate is required to have exactly 7 chars. 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 = nm ways to construct a function from a set with m elements to a set with n elements.

  5. 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).

  6. The Sum Rule: Suppose that a procedure can be completed by either performing one task or another task. If there are n1 ways to do one of the tasks and n2 ways to do the other task and if these tasks can not be done at the same time, then there are n1 +n2 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.

  7. The Generalized Sum Rule: If a procedure can be completed by performing one of m tasks and if there are n1 ways to do the first task and n2 ways to do the second task, …, and nm ways to do the mth task and no two of the tasks can be done at the same time, then there are n1 +n2 + … + nm 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.

  8. 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, P6, P7, or P8, where Pi 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 P6 + P7 + P8 ways. Similarly, when we choose each character in a password, the sum rule tells us that there are 26 + 26 + 10 = 62 ways to choose each character. Then by the product rule, there are 626 ways to complete P6, 627 ways to complete P7, and 628 ways to complete P8. So there are 626 + 627 + 628 ways to choose a valid password under the given constraints. That is, there are 221,918,520,426,688 different valid passwords.

  9. 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 N6 + N7 + N8 ways to choose a password with no digits if Ni is the number of ways to choose a password of length i with no digits. Then the sum rule tells us there are 26 + 26 = 52 ways to choose each character in one of these passwords. So by the product rule there are 526 + 527 + 528 ways to choose a password with no digits. Subtracting, there are 167,410,949,583,040 valid passwords left.

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

  11. The Principle of Inclusion-Exclusion: Suppose that a procedure can be completed by either performing one task or another task. If there are n1 ways to do one of the tasks and n2 ways to do the other task and if there are m ways to do both tasks at the same time, then there are n1 +n2 – 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 27 bit strings of length 8 that start with a 1 bit (choose the last 7 bits), 26 bit strings of length 8 that end with two 0 bits (choose the first 6 bits), and 25 bit strings of length 8 that start with a 1 bit and end with two 0 bits. So there are 27 + 26 – 25 = 160 desired bit strings.

More Related