# Solutions to First Midterm Exam

#### 26 February 2007

• There were seven problems for 100 total points. Scale was A=90, C=60.
• The first five questions are true/false, with five points for the correct boolean answer and up to five for a correct justification.
• Question 6 has numerical answers -- you may give your answer in the form of an expression using arithmetic operations, powers, falling powers, or the factorial function. If you give your answer using the "choose" notation, also give it using only operations on this list.

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

• Question 1 (10): True or false with justification: If A, B, and C are any three finite sets, and A∩B∩C = ∅, then |A∪B∪C| ≤ |A| + |B| + |C|.

TRUE. With the given condition on |A∩B∩C|, we can use Inclusion-Exclusion to get this result easily because then |A∪B∪C| = |A| + |B| + |C| - |A∩B| - |A∩C| - |B∩C|, and the last three terms subtract non-negative things.

Even without that condition, the conclusion is still true. If we count the elements of A, then those of B, and then those of C, we count every element of A∪B∪C at least once, so the number of items in the union can be no bigger than the number of times we count.

• Question 2 (10): True or false with justification: No function can be both O(n2) and O(n3).

FALSE. In fact any function that is O(n2), such as 0, 1, n, or n2 itself, is also O(n3) because we know that big-O relations among polynomials depend only on the degree of the leading term, where f = O(g) if and only if f's leading term has no greater degree than g's.

As we see in question 7 below, I accidently copied my first draft for this test instead of the later one -- I planned to change this question to "no function can be both O(n3) and Ω(n2)" which is still false.

• Question 3 (10): True or false with justification: Let n be any natural number. The sum for i from 0 to n of (n choose i) is exactly half the sum for j from 0 to n+1 of (n+1 choose j).

TRUE. These sums are the sums of all entries on the n'th row and n+1'st row, respectively of Pascal's Triangle, and are equal to 2n and 2n+1. It was enough to quote this fact, but there are several ways to justify it:

• The entries of the n'th row each count the length of the size-i subsets of an n-element set for some i, so their total is the number of all such sets which is 2n.
• By Pascal's Identity, each entry (n choose i) contributes to exactly two entries on the next row, (n+1 choose i) and (n+1 choose i+1), so the sum of the next row contains two copies of each entry on the n'th row and is thus twice the sum of the n'th row.

• Question 4 (10): True or false with justification: Consider the set of four-letter strings over the alphabet {a,b,c}. A majority of these strings have two or more c's.

FALSE. We can count the strings with two or more, (4 choose 2) times 22 = 24 with exactly two, (4 choose 1) times 2 = 8 with exactly three, and (4 choose 4) = 1 with four for a total of 33 strings with two or more, fewer than half of the 34 = 81 total strings. We could also have counted the 24 = 16 with no c's and the (4 choose 1) times 23 = 32 with one c, and seen that the 48 of these are a majority of the 81 total.

Several of you argued that because the number of strings with two or more a's and the number with two or more b's must equal the number with two or more c's, this common number cannot be a majority. This was a nice observation about the symmetry but it doesn't immediately give you a contradiction. Let the number with two or more c's be t. There are then t with two or more a's and t with two or more b's. If we call these three sets A, B, and C, we are actually in the situation of Question 1, because no string can be in A, B, and C. But the total size of the set, is 3t minus the sizes of A∩B, A∩C, and B∩C. To argue that t can't be bigger than 81/2, we'd have to say that these three intersections have some size s such that 3t - 3s can only be ≤81 if t≤81/2. To do this we'd have to calculate s, which none of you did. (The size of A∩B is 6, so this argument would have worked if you found this number because 3t - 3(6) ≤ 81 forces t ≤ 33.

• Question 5 (10): True or false with justification: Consider the set of three-letter strings over the alphabet {a,b,c,d}. A majority of these strings have no letter occurring more than once.

FALSE. The total number of strings is 43 = 64 (first counting problem) and the total with no repeats is 43 = 24 (second counting problems. But 24 is not a majority of 64.

• Question 6 (30): A conference is being held over five days, Monday through Friday. The conference chair must choose which topics will be discussed on which days. (It is not possible to discuss more than one topic on the same day.) There are eight possible topics, which we will call A, B, C, D, E, F, G, and H.

• (a,5) In how many ways can the chair pick one topic for each day, if no topic is discussed on more than one day?

Second counting problem, 85 = 8*7*6*5*4 = 6720.

• (b,5) In how many ways can the chair choose a set of five topics to be discussed?

Third counting problem, (8 choose 5) = 85/5! = 6720/120 = 56.

• (c,5) Now suppose that any topic may be discussed on more than one day. In how many ways can the chair schedule one topic for each day?

First counting problem, 85 = 215 = 32768.

• (d,5) In how many ways can the number of days for each topic be assigned? (For example, one of these ways is "two days for B, one day for F, and two days for H".)

Fourth counting problem, counting binary strings with 5 zeros and 8-1=7 ones, (12 choose 5) = 12*11*10*9*8/1*2*3*4*5 = 11*9*8 = 792.

• (e,5) How many of the answers to (a) discuss B on Wednesday and don't discuss G at all?

We must pick four topics for Monday, Tuesday, Thursday, and Friday with no repeats from the set {A,C,D,E,F,H}. This is the second counting problem, 64 = 6*5*4*3 = 360.

• (f,5) How many of the answers to (c) discuss B on Wednesday and don't discuss G at all?

Now we choose four topics with repeats possible from seven possibilities (we are no longer barred from using B on other days). This is the first counting problem, 74 = 2401.

• Question 7 (20): Let g be a function such that g = θ(n). This was a mistake, it should have said that g = θ(1) to match the following definition. (Remember that this means that there exist a natural number n0 and positive real numbers c and d such that for all n with n ≥ n0, d < g(n) < c. Let the function f be defined by the recurrence f(n+1) = f(n) + g(n) for all natural numbers n, with the initial condition f(0) = 0. Prove that f(n) = θ(n). Which of course it isn't if g = θ(n), in that case f would be θ(n2).

(Hint: Use ordinary induction on all n with n ≥ n0 to show that for those n, f(n) is between two linear functions.)

I was fairly generous with partial credit, but I gave no one full credit because you should really have noticed the mistake in the course of trying to prove that f = θ(n) in the case that g = θ(n), in which case it is false. Either that, or you could have used the d < g(n) < c statement to prove f = θ(n) as I intended. I do apologize for the mistake, which I should have caught before or during the test.

Here's the intended proof. Let n0 be the number after which the bounds on g(n) hold. Then f(n0) is some number a, which we don't know much about because we don't know much about the g(i)'s that were summed to get it. But for n ≥ n0, f(n) is equal to a plus the sum, for i from n0+1 to n-1, of g(i). [We can prove this assertion by ordinary induction starting at n0: the base case of n = n0 reduces to a = a, and given the n case we can prove the n+1 case easily -- f(n+1) = f(n) + g(n) = (sum from n0+1 to n-1 of g(i)) + g(n) = (sum from n0+1 to n of g(i)).] Then because each of these g(i)'s is at least d, f(n) ≥ a + d(n-n0), and because each g(i) is at most c, f(n) ≤ a + c(n-n0).

We've now trapped f(n) between two linear functions, which is enough to show that it is θ(n) as suggested in the hint. If we want to work directly from the definition, we could say that f(n) = Ω(n) because it dominates dn/2 eventually, and f(n) = O(n) because it is dominated by 2cn eventually. Where this domination starts depends on the relative values of a, c, and d, but it must happen eventually.