Chapter 6 - Counting 6.1 - The Basics of Counting Theorem 1 (The Product Rule). If every task in a set of k tasks must be done, where the first task can be done in n 1 ways, the second in n 2 ways, and in general the ith can be done in n i ways, and the way in which the ith task is completed doesn t affect the number of ways to complete the remaining tasks, then the k tasks can be done in n 1 n 2... n k ways. The Product Rule can be viewed as counting the number of elements in the Cartesian product of the finite sets A 1, A 2,..., A k : A 1 A 2... A k = A 1 A 2... A k Example 1. (a) How many functions are there from a set of three elements into a set of four elements? (b) How many functions are there from a set of m elements into a set of n elements? Example 2. (a) How many 1-1 functions are there from a set of three elements into a set of four elements? (b) How many 1-1 functions are there from a set of m elements into a set of n elements? Example 3. (a) How many nine digit Social Security Numbers are there? (b) How many of them are even? 1
Example 4. How many subsets are there of a set of n elements? i.e., what is the order of the power set of a set of n elements? Theorem 2 (The Sum Rule). If exactly one task in a set of k tasks must be done, where the first task can be done in n 1 ways, the second in n 2 ways, and in general the ith can be done in n i ways, and the way in which the ith task is completed doesn t affect the number of ways to complete the remaining tasks, then the number of ways to choose an perform that one task is n 1 + n 2 + + n k. Example 5. A regional manager must be chosen to oversee a three-state area. State A has 10 candidates, state B has 7 candidates, and state C has 15 candidates. In how many ways can the choices be made? Theorem 3 (The Division Rule). If a task can be done using a procedure that can be carried out in n ways, and for every way w exactly d of the n ways correspond to way w, then there are n d ways to do the the task. Example 6. How many ways are there to seat 7 people around a circular table (with 7 seats)? 2
Example 7. Suppose a state has license plates formatted as either two letters followed by four digits, or one letter followed by five digits. How many possible license plate numbers are there? Example 8. How many cards in a standard deck of 52 are either jacks or spades? Recall the following from chapter 2: Theorem 4 (The Principle of Inclusion/Exclusion). If A, B, and C are finite sets, then A B = A + B A B and A B C = A + B + C A B A C B C + A B C Example 9. (a) How many strings of 8 English letters are there that contain at least one vowel, if letters can be repeated? (b) How many such strings contain exactly one vowel? 3
Tree Diagrams Tree diagrams can be used to solve counting problems, although this is only practical if the number of choices/ways is relatively small. Example 10. In the game of Num two players start with n toothpicks. Each of the two players alternates picking up either one or two toothpicks, and the last player to pick up a toothpick loses. With n = 4, in how many ways can the game turn out? What is a winning strategy? What happens if we start with 7 toothpicks? 6.2 - The Pigeonhole Principle Theorem 5 (The Pigeonhole Principle, or The Dirichlet Drawer Principle). If k is a positive integer and k + 1 objects [pigeons] are placed into k boxes [drawers], there there is at least one box containing two or more of the objects. Theorem 6 (The Generalized Pigeonhole Principle). If N objects are placed into k boxes, then there is at least one box containing N k objects. This can be stated in terms of sets as follows: Theorem 7 (Generalized Pigeonhole Principle, Set Version). If A and B are sets and f : A B is a function, then there exists at least one element b B such that A f 1 (b) B 4
Example 11. How many people do we need in a room to guarantee that two have the same birthday? Example 12. Among 5000 people there are at least how many who have the same birthday? Example 13. Suppose we have a bag with 10 Twix bars, 8 KitKat bars, and 9 Hershey s bars. (a) How many bars do we need to remove in order to guarantee that we have one of each kind? (b) How many to guarantee that we have three of the same kind? 5
Example 14. Any sequence of n 2 + 1 distinct numbers has a subsequence of n + 1 or more that is either strictly increasing or strictly decreasing. 6