Evaluations

Evaluation: 2015 Winter Midterm

Author: Michiel Smid

1 . The Carleton Computer Science Society has a Board of Directors consisting of a President and a seven-person Advisory Board. The President cannot be on the Advisory Board. Let $n$ be the number of students in Carleton's Computer Science program, where $n \geq 8$. In how many ways can a Board of Directors be chosen?
(a)
$n + {n \choose 7}$
(b)
$n \cdot {n \choose 7}$
(c)
$(n - 7) + {n \choose 7}$
(d)
$(n - 7) \cdot {n \choose 7}$

2 . Let $A$ be a set of 7 elements and let $B$ be a set of 15 elements. How many functions $f : A \rightarrow B$ are there?
(a)
$15!/7!$
(b)
$15^7$
(c)
$7^{15}$
(d)
${15 \choose 7}$

3 . Let $A$ be a set of 7 elements and let $B$ be a set of 15 elements. How many one-to-one (i.e., injective) functions $f : A \rightarrow B$ are there?
(a)
$9 \cdot 10 \cdot 11 \cdot 12 \cdot 13 \cdot 14 \cdot 15$
(b)
$10 \cdot 11 \cdot 12 \cdot 13 \cdot 14 \cdot 15$
(c)
$8 \cdot 9 \cdot 10 \cdot 11 \cdot 12 \cdot 13 \cdot 14 \cdot 15$
(d)
$9 \cdot 10 \cdot 11 \cdot 12 \cdot 13 \cdot 14$

4 . Consider strings consisting of the characters $a$, $b$, and $c$. Such a string is called valid, if no two consecutive characters are equal. Thus, $abacbac$ is valid, whereas $abaccac$ is not valid.
Let $n \geq 1$ be an integer and let $V_n$ be the number of valid strings of length $n$. Which of the following is true?
(a)
$V_n = 3^n - (n - 1) \cdot 3$
(b)
$V_n = 3^n - (n - 1) \cdot 3 \cdot 3^{n-2}$
(c)
$V_n = 3 \cdot 2^{n-1}$
(d)
None of the above.

5 . Consider strings of length 99 consisting of the characters $a$, $b$, and $c$. How many such strings are there that start with $abc$ or end with $bbb$?
(a)
$3^{96} + 3^{96}$
(b)
None of the above.
(c)
$2 \cdot 3^{96} - 3^{93}$
(d)
$3^{99} - 2 \cdot 3^{96}$

6 . What does $$ \sum_{k=2}^{n-1} (k-1)(n-k) $$ count?
(a)
The number of 3-element subsets of an $(n+1)$-element set.
(b)
The number of 3-element subsets of an $(n-1)$-element set.
(c)
The number of 3-element subsets of an $n$-element set.
(d)
The number of times you fart when running algorithm $\Silly(n)$.

7 . What is the minimum number of people needed so that we can guarantee that at least three of them have the same birthday? (We ignore leap years; thus, a year has 365 days.)
(a)
$2 \cdot 365 + 1$
(b)
$365^2 + 1$
(c)
$2 \cdot 365$
(d)
$365^2$

8 . What is the coefficient of $x^{17}$ in the expansion of $(17 + 2x)^{99}$?
(a)
$2^{17} \cdot 17^{82} \cdot {99 \choose 17}$
(b)
$2^{16} \cdot 17^{82} \cdot {99 \choose 16}$
(c)
$2^{82} \cdot 17^{17} \cdot {99 \choose 17}$
(d)
None of the above.

9 . How many solutions are there to the equation $x_1 + x_2 + x_3 = 99$, where $x_1 \geq 0$, $x_2 \geq 0$, and $x_3 \geq 0$ are integers?
(a)
${102 \choose 3}$
(b)
${102 \choose 2}$
(c)
${101 \choose 2}$
(d)
${101 \choose 3}$

10 . The function $f: \mathbb{N} \rightarrow \mathbb{N}$ is defined by $$ \begin{align} f(0) &= 15 \\ f(n) &= f(n - 1) +6n - 4\; \ \mathrm{for}\ n \geq 1 \end{align} $$ What is $f(n)$?
(a)
$f(n) = 3n^{2} - 2n + 15$
(b)
$f(n) = 3n^{2} - n + 15$
(c)
$f(n) = 3n^{2} + n + 15$
(d)
$f(n) = 3n^{2} + 2n + 15$

11 . Consider strings consisting of the characters $a$, $b$, and $c$. Such a string is called valid, if it does not contain the substring $aaa$. Let $S_n$ be the number of valid strings of length $n$. Which of the following is true?
(a)
$S_n = 2 \cdot S_{n-1} + S_{n-2} + 2 \cdot S_{n-3}$
(b)
$S_n = 2 \cdot S_{n-1} + 2 \cdot S_{n-2} + 2 \cdot S_{n-3}$
(c)
$S_n = 2 \cdot S_{n-1} + 2 \cdot S_{n-2}$
(d)
$S_n = 2 \cdot S_{n-1} + 2 \cdot S_{n-2} + S_{n-3}$

12 . Let $n \geq 1$ be an integer and let $S_n$ be the number of ways in which $n$ can be written as a sum of 1s and 2s, such that
  • the order in which the 1s and 2s occur in the sum matters, and
  • it is not allowed to have two consecutive 1s.
For example, if $n = 7$, then $$ 7 = 1 + 2 + 1 + 2 + 1 $$ is allowed, whereas $$ 7 = 1 + 2 + 1 + 1 + 2 $$ is not allowed.
Which of the following is true?
(a)
$S_n = S_{n-2} + S_{n-3}$
(b)
$S_n = S_{n-1} + S_{n-2} + S_{n-3}$
(c)
$S_n = S_{n-1} + S_{n-3}$
(d)
$S_n = S_{n-1} + S_{n-2}$

13 . Consider the following recursive algorithm $\Fib$, which takes as input an integer $n \geq 0$:

$\mathbf{Algorithm}\ \Fib(n)\mathrm{:}$
$\mathbf{if}\ n = 0\ \mathrm{or}\ n = 1$
$\mathbf{then}\ f = n$
$\mathbf{else}\ f = \Fib(n - 1) + \Fib(n - 2)$
$\mathbf{endif};$
$\mathbf{return}\ f$

When running $\Fib(99)$, how many calls are there to $\Fib(95)$?
(a)
7
(b)
5
(c)
4
(d)
6

14 . Consider the following recursive algorithm $\NationalAnthem$, which takes as input an integer $n \geq 1$, which is a power of 2:

$\mathbf{Algorithm}\ \NationalAnthem(n)\mathrm{:}$
$\mathbf{if}\ n = 1$
$\mathbf{then}\ \mathrm{sing}\ {\it O\ Canada}\ \mathrm{once}$
$\mathbf{else}\ \NationalAnthem(n / 2);$
$\elsesp \mathrm{sing}\ {\it O\ Canada}\ \mathrm{once};$
$\elsesp \NationalAnthem(n / 2)$
$\mathbf{endif}$

For $n$ a power of 2, let $S(n)$ be the number of times you sing O Canada when running algorithm $\NationalAnthem(n)$. Which of the following is true?
(n.b., $\log$ denotes the base-2 logarithm)
(a)
$S(n) = 1 + \log n$
(b)
$S(n) = 2n - 1$
(c)
$S(n) = 1 + n \log n$
(d)
$S(n) = 2n + 1$

15 . You flip a fair coin 5 times. Define the event
  • A = "the number of heads is odd".
What is $\Pr(A)$?
(a)
3/8
(b)
4/8
(c)
5/8
(d)
6/8

16 . You flip a fair coin 11 times. Define the events
  • A = "the number of heads is odd"
and
  • B = "the number of tails is even".
Which of the following is true?
(a)
$\Pr(A) < \Pr(B)$
(b)
$\Pr(A) = \Pr(B)$
(c)
$\Pr(A) > \Pr(B)$
(d)
None of the above.

17 . In order to celebrate that the COMP 2804 midterm went well, you go to your neighborhood pub. This pub has 16 different beers on tap:
  • There are 7 beers of the pilsner type.
  • There are 5 beers of the India pale ale type.
  • There are 4 beers of the German wheatbeer type.
You order 4 different beers with at least one beer of each type. What is the number of ways in which you can do this? (The order in which you order the beers does not matter.)
(a)
${16 \choose 4} - {7 \choose 3} - {5 \choose 3} - {4 \choose 3}$
(b)
${7 \choose 2} \cdot 5 \cdot 4 + 7 \cdot {5 \choose 2} \cdot 4 + 7 \cdot 5 \cdot {4 \choose 2}$
(c)
${16 \choose 4}$
(d)
None of the above.