# Solutions to First Practice Midterm Exam

#### 18 February 2009

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 30 points
Q6: 30 points
Total: 100 points
```

• Question 1 (10): True or false with justification: Over 90% of the ten-letter sequences of a's and b's have at least two a's and at least two b's.

TRUE. There are 210 = 1024 total ten-letter sequences. The ones that do not have at least two a's and at least two b's are the ones with exactly 0, 1, 9, or 10 a's -- there are (10 choose 0) + (10 choose 1) + (10 choose 9) + (10 choose 10) = 1 + 10 + 10 + 1 = 22, much less than 10% of 1024.

• Question 2 (10): True or false with justification: Consider bridge hands, which are thirteen-card subsets of the 52-card deck. The number of bridge hands, consisting of twelve cards of one suit and an ace of another suit, is less than 200.

TRUE. To pick such a hand we pick the suit (4), pick twelve cards of that suit (13), and pick the suit for the ace (3). The total is 4*13*3 = 156.

• Question 3 (10): True or false with justification: The number of thirteen-card bridge hands that either contain all four aces, or contain all four kings, or both, is strictly less than 2 times (48 choose 9).

TRUE. There are (48 choose 9) hands with all four kings, and (48 choose 9) with all four aces, because in each case we must pick 9 of the other 48 cards. Because there are some hands, (44 choose 5) of them in fact, that have both four aces and four kings, the total is less than 2 times (48 choose 9).

• Question 3 (10): True or false with justification: There are over a million nine-letter words that contain all the letters that occur in the word "CAMBRIDGE".

FALSE. Reordering these nine distinct letters can be done in 9! ways, and 9! = 362,880 which is less than a million.

• Question 5 (30): In this problem you will count various subsets of the three-letter strings that use only letters that occur in the word "CAMBRIDGE".
• (a,5) How many such strings are there in all?

First Counting Problem, 93 = 729.

• (b,5) How many such strings do not contain a repeated letter?

Second Counting Problem, 93 = 9*8*7 = 504.

• (c,5) In how many of these strings do the letters occur in the same order as in the word "CAMBRIDGE", with letters possibly repeated? (For example, "BRR" is such a word.)

Fourth Counting Problem, n=9, k=3, (n+k-1 choose k) = (11 choose 3) = 11*10*9/1*2*3 = 165. It doesn't matter that the order on the letters is different from the usual alphabetical order.

• (d,5) How many of these strings are in both the set counted in part (b) and the set counted in part (c)?

Third Counting Problem, (9 choose 3) = 9*8*7/1*2*3 = 84.

• (e,5) How many of the strings counted in (b) have the letters in alphabetical order, as in the word "AEM"?

Same as (e), (9 choose 3) = 84.

• (f,5) How many of the strings counted in (a) have two consonants and a vowel, with the vowel in the middle, as in "BIB" or "DIG"? (Here "A", "E", and "I" are vowels and the other six letters are consonants.)

Product Rule, 6*3*6 = 108.

• Question 6 (30): This question involves strings of different lengths over the alphabet {a,b}. Let X be the set of strings that begin with "a" and never have two "b"'s in a row. Let Y be the set of strings that never have three "a"'s or three "b"'s in a row.
• (a,5) Find all the four-letter strings in X.

aaaa, aaab, aaba, abaa, abab -- of the others eight start with "b" and three (aabb, abba, abbb) have a "bb", in all these make the 16 total four-letter strings.

• (b,5) Compute how many four-letter strings are in Y. (Hint: You can always examine all 24 four-letter strings, but you could also use Inclusion/Exclusion to count the strings that have the first three letters equal, the last three letters equal, or both.)

There are 16 total four-letter sequences. Four have the first three letters equal, four have the last three equal, two have both, 16 - 4 - 4 + 2 = 10.

• (c,10) For any non-negative integer n, let f(n) be the number of strings of length n in X. Argue that for any n, f(n+2) = f(n+1) + f(n). (Hint: How can a string in X begin? When do you know that you can delete some initial letters of a string in X and be left with another string in X?)

A string of length n in X must begin with "a". If it begins "aa", it consists of an "a" followed by a string of length n-1 in X. If it begins "ab", the part following the "ab" must also be a string in X, of length n-2, because it must start with a and contain no "bb"'s. So there are f(n-1) strings of length n in X starting with "aa" and f(n-2) starting with "ab". Since no string begins with both "aa" and "ab", we can use the Sum Rule and get the desired formula. Note that the "for any n" is actually false -- the argument above does not work if the remainder string is empty, for example. Here f(0) = 0 because the empty string is not in X -- it does not begin with "a". The first n for which the formula is true is n=3 -- for n=2 it is wrong because f(2) = 2, f(1) = 1, but f(0) = 0.

• (d,10) For any non-negative integer n, let g(n) be the number of strings of length n in Y. Argue that for any n, g(n) = 2f(n). (Hint: If w is a string of a's and b's, I can map it to v, another string of a's and b's of the same length, as follows. When a letter of w is different from the previous letter, or is the first letter of w, write an "a" in v. If the letter of w is the same as the previous letter, write a "b" in v. If w is in Y, what can we tell about v? What does this say about the number of strings in X and Y of that length?)

If w is a string in Y, the first letter of v is an "a", and the remaining letters could be anything except that they cannot have two b's in a row. Two b's in a row in v would mean three consecutive letters the same in w. So the mapping on strings takes Y to X. For every string in X, there are exactly two strings in Y that map to it, one starting with "a" and one with "b". Since the mapping preserves length, g(n) must be exactly twice f(n).