Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Harvard University Computer Science 20 In-Class Problems 25 Monday, April 4, 2016 Author: Jack Dent Executive Summary 1. Fundamental rules for counting • The sum rule: If sets A and B are disjoint, A has a elements, and B has b elements, their union has a + b elements. This permits a “divide and conquer” strategy. • The difference rule: Suppose set B has b elements and its subset A has a elements. Then the set difference B − A has b − a elements. This rule is useful when it is easy to count sets B and its subset A, but there is no simple way to count B − A directly. • The product rule: Suppose that set A has m elements and set B has n elements. The Cartesian product A × B is the set of ordered pairs (a, b), where a is an element of A and b is an element of B. The set A × B has mn elements. • The power rule: If A has n elements and you select a sequence of r elements with replacement from A, there are nr possible sequences. • The division rule: When counting, it is fine to count things more than once, provided that everything gets overcounted the same number of times and that you know that number and divide by it. PROBLEM 1 Twelve athletes are competing in a race. (A) How many possibilities are there for the podium positions (first, second, and third place)? (B) Suppose now that two people tie in first place, three people tie in second place, and 2 people tie in third. How many different possibilities for the podium are there now? Solution. (A) Ordering the athletes and dividing out the irrelevant positions, we have 12! 9! . (B) Dividing by the irrelevant positions, and dividing by the number in each podium position since 12! we don’t care about ordering, we have 2!·3!·2!·5! . PROBLEM 2 Compute the number of anagrams for each of the following words. Assume that anagrams need not be proper words. (A) “lewis” (B) “engineer” (C) “mathematician” 1 Solution. (A) There are no repeated characters, so there are 5! anagrams. 8! (B) There are two ‘n’s and three ‘e’s, so there are 2!·3! anagrams. (C) There are two ‘m’s, three ‘a’s, two ‘t‘s and two ‘i’s, so there are 13! 2!·3!·2!·2! anagrams. PROBLEM 3 (A) A dodecahedron has 12 faces, each a regular pentagon. How many edges does it have? (B) Three faces of the dodecahedron meet at each vertex. How many vertices does the dodecahedron have? Solution. (A) Each face has 5 edges, and each edge is shared by two faces, so there are 12×5 2 = 30 edges. (B) Each face has 5 vertices, and each vertex is shared by three faces, so there are 12×5 = 20 3 vertices. PROBLEM 4 A license plate consists of either • 3 letters followed by 3 digits (standard plate) • 5 letters (vanity plate) • 2 characters - letters or numbers (big shot plate) Compute the number of different possible license plates. Solution. 263 × 103 + 265 + 362 PROBLEM 5 How many of the billion numbers in the range from 1 to 109 (inclusive) contain the digit 1? Solution. By the product rule, 99 of the numbers between 0 at 109 − 1 do not contain a 1 and neither does 109 , so there are 109 − (99 − 1) numbers that do contain the digit 1. PROBLEM 6 (BONUS) Vandermonde’s Identity states that: n X r s r+s · = k n−k n k=0 2 Give an argument for why both sides of the equation are equivalent. Solution. Suppose we have two groups of people, R and S with |R| = r and |S| = s. We can select a group ways, which is the right side of the equation. Now suppose of n people from the set R ∪ S in r+s n we select k people from set R, and the remaining n − k from set S. Multiplying the number of s possible combinations in both sets, we can do this in kr · n−k ways. Sumimg over all k between 0 and n inclusive, which is the left side of the equation, we obtain the total number of ways to select n people across both sets, and so the identity holds. 3