# Practice Exam Solutionsfor First Midterm

### Directions:

• There are seven problems on pages 2-7, for 100 total points. Probable scale is 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.

Question text is in black, solutions in blue.

```  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: The number of binary strings of length n, with exactly k ones, is (n choose k).

TRUE. There are n locations for ones, and we must choose k of them. The Third Counting Problem says that there are exactly (n choose k) sets of size k.

• Question 2 (10): True or false with justification: There are more than 50 different four-element subsets of the set {a,b,c,d,e,f,g,h}.

TRUE. Again by the Third Counting Problem, the number is (8 choose 4) which is (8*7*6*5)/(1*2*3*4) = 70, which is more than 50.

• Question 3 (10): True or false with justification: If f is a function defined by the rules f(0) = 393 and f(n+1) = f(n) + 146 for all natural numbers n, then f(n) is odd for all natural numbers n.

TRUE. We prove this by ordinary induction on n, where P(n) is "f(n) is odd". For n=0, f(0) = 393 which is odd. Assume that f(n) is odd, then f(n+1) is f(n) + 146, which is the sum of an odd number (by the IH) and an even number and is therefore odd.

• Question 4 (10): True or false with justification: If the function T satisfies the rules T(0) = 0, T(1) = 0, and T(n+1) = T(n) + O(n) for all positive integers n, then T(n) = O(n log n).

FALSE. To show this to be false we only need one example of such a T. Let T(n+1) = T(n) + n, then T(2) = 1, T(3) = 3, T(4) = 6, and in general T(n) = (n choose 2) = n(n-1)/2. This function is not O(n log n) because T(n)/(n log n) is n/(2 log n) - 1/(2 log n) and this is not bounded by any constant as n increases.

• Question 5 (10): True or false with justification: If A, B, and C are any three finite sets, then the size of the direct product A × (B ∪ C) is at least |A||B| + |A||C|.

FALSE. This might be true, if B and C are disjoint, but it is false in general. For example, let B = C = {x} and A = {y}. The product A × (B ∪ C) has only one element (y,x), but |A||B| + |A||C| = 1*1 + 1*1 = 2.

• Question 6 (30): A package of Chewy Candies contains ten candies, each of which is either Cherry, Lemon, Orange, or Strawberry.

• (a,5) How many different possible packages are there if we do consider the order in which the candies occur? (So a package might be described by the string "CCOLCLSCCO".)

First Counting Problem, k=10, n=4, answer nk = 410 = 220 = 1048576. (It is not necessary to multiply out the power -- "410" is a full-credit answer.)

• (b,5) How many possibilities are there for the set of flavors that occur in the package?

There are 24 = 16 possible subsets of the set of flavors {C,L,O,S}. But one of these, the empty set, could not be the set of flavors in the package because the package has candies in it and these candies must have at least one flavor between them. So the answer is 15 -- you could also compute this as (4 choose 1) + (4 choose 2) + (4 choose 3) + (4 choose 4) = 4 + 6 + 4 + 1 = 15, counting the ses of size 1, 2, 3, and 4 flavors separately.

• (c.10) How many of the answers to (a) contain at least one Cherry and at least one Lemon?

We use the Double-Counting Rule to find the number with no Cherries or no Lemons, then subtract this number from 410. There are 310 possible packages with no Cherries because each of the ten candies could have any of the three other flavors. Similarly there are 310 packages with no Lemons. There are 210 with no Cherries and no Lemons, as each candy in such a package may be either Orange or Strawberry. So the number with no Cherries or no Lemons is 310 + 310 - 210, and the total with at least one Cherry and at least one Lemon is 410 - 310 - 310 + 210. Again it is not required to compute this number out, but it is 1048576 - 58049 - 58049 + 1024 = 933502, about 89% of the possible packages.

• (d,10) How many different possible packages are there if we do not consider the order in which the candies occur? (So a package might be described as "five cherry, two lemon, two orange, one strawberry".)

By the Fourth Counting Problem, we are counting the different multisets of size 10 taken from a 4-element set. These correspond to strings of 10 zeros and 4-1 = 3 ones, so there are (13 choose 3) or (13 choose 10) of them. This number is (13*12*11)/(1*2*3) = 286. (Here "133/3!", for example, is a full-credit answer.)

• Question 7 (20): Remember that Pascal's Identity says that for any natural numbers a and b, (a+1 choose b) = (a choose b) + (a choose b-1). Let k be any natural number. Prove that for all natural numbers n, (n+k+1 choose k+1) is equal to the sum, for i from 0 to n, of (k+i choose k). (Hint: Use ordinary induction on n, starting with n=0.)

Proof by induction on n, starting from n=0.

Base case, n=0, we must show that (k+1 choose k+1) is equal to the sum, for i from 0 to 0, of (k+i choose k). But (k+1 choose k+1) is 1 and the sum contains exactly one term which is (k choose k), and thus is also 1.

Inductive case: Assume that (n+k+1 choose k+1) is the sum for i for 0 to n of (k+i choose k). We must show that (n+1+k+1 choose k+1) is equal to the sum for i from 0 to n+1 of (k+i choose k). This sum is equal to the sum in the IH plus the new i=n+1 term, which is (k+n+1 choose k). So by the IH, this new sum is equal to (n+k+1 choose k+1) + (n+k+1 choose k). This fits the given Pascal's Identity above with a = n+k+1 and b = k+1, so the new sum equals (a+1 choose b) which is (n+k+2 choose k+1). This is exactly what we need to prove the new sum to be to complete the inductive step.