-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d7edf7
commit 45de12f
Showing
24 changed files
with
172 additions
and
50 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/content/questions/comp2804/2018-winter-final/1/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Let's choose 12 beer bottles out of the 20: $ \binom{20}{12} $ | ||
|
||
Let's choose 18 cider bottles out of the 50: $ \binom{50}{18} $ | ||
|
||
$ \binom{20}{12} \cdot \binom{50}{18} $ |
17 changes: 12 additions & 5 deletions
17
src/content/questions/comp2804/2018-winter-final/10/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
On SundayEveningExam$ (n) $, the line \enquote{I don't like Sunday evening exams} is printed n times | ||
On SundayEveningExam$ (n-1) $, the line \enquote{I don't like Sunday evening exams} is printed n-1 times | ||
On SundayEveningExam$ (n-2) $, the line \enquote{I don't like Sunday evening exams} is printed n-2 times | ||
... | ||
On SundayEveningExam$ (1) $, the line \enquote{I don't like Sunday evening exams} is printed 1 time | ||
On SundayEveningExam$ (n) $, the line \enquote{I don't like Sunday evening exams} is printed n times | ||
|
||
On SundayEveningExam$ (n-1) $, the line \enquote{I don't like Sunday evening exams} is printed n-1 times | ||
|
||
On SundayEveningExam$ (n-2) $, the line \enquote{I don't like Sunday evening exams} is printed n-2 times | ||
|
||
... | ||
|
||
On SundayEveningExam$ (1) $, the line \enquote{I don't like Sunday evening exams} is printed 1 time | ||
|
||
$ P(n) = n + (n-1) + (n-2) + \text{...} + 1$ | ||
|
||
Using the 1st Formula given on the Exam Sheet, it translates the above to the following: | ||
|
||
$ P(n) = \frac{n(n+1)}{2} $ |
9 changes: 7 additions & 2 deletions
9
src/content/questions/comp2804/2018-winter-final/11/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
First, we choose which 3 of the 18 rolls are 5: $ \binom{18}{3} $ | ||
We also need to calculate the prbability of rolling a 5 exactly 3 times: ${( \frac{1}{6})}^3 $ | ||
We also need to calculate the probability of not rolling a 5 exactly 15 times: ${( \frac{5}{6})}^{15} $ | ||
|
||
We also need to calculate the prbability of rolling a 5 exactly 3 times: ${( \frac{1}{6})}^3 $ | ||
|
||
We also need to calculate the probability of not rolling a 5 exactly 15 times: ${( \frac{5}{6})}^{15} $ | ||
|
||
$ \binom{18}{3} \cdot {( \frac{1}{6})}^3 \cdot {( \frac{5}{6})}^{15} $ | ||
|
||
$ = \binom{18}{3} \cdot ( \frac{1^3}{6^3}) \cdot ( \frac{5^{15}}{6^{15}}) $ | ||
|
||
$ = \binom{18}{3} \cdot \frac{5^{15}}{6^{18}} $ |
3 changes: 3 additions & 0 deletions
3
src/content/questions/comp2804/2018-winter-final/12/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
To guarantee that a string is a palindrome in this case, we have to ensure that the first half of the string matches the second half (but reversed). | ||
|
||
At each position in the "half of the string", there is a $\frac{1}{3}$ chance that the corresponding character in the other half of the string is the same since there are 3 character options (a, b, c) and only 1 of those can match. | ||
|
||
Since the string is an odd integer, half of a string would be: $\frac{n-1}{2}$. So if $n = 3$, then half of the string would be $\frac{3-1}{2} = 1$. This makes sense, as we would check if the 1st and last character are the same, and the 2nd character we know would already be the same as itself. | ||
|
||
This means that the total probability a string is a palindrome is: $( \frac{1}{3})^{n-1/2}$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/content/questions/comp2804/2018-winter-final/14/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
The difference in string $a-b$ is non-zero at each position only if $a_i$ is 1 and $b_i$ is 0 or $a_i$ is 0 and $b_i$ is 1, for all $1 leq i leq 77$ | ||
|
||
Let $X_i$ be 1 if $a_i$ and $b_i$ are different and 0 otherwise | ||
|
||
$ Pr(X_i = 1) = \frac{1}{4} \cdot \frac{3}{4} + \frac{3}{4} \cdot \frac{1}{4} $ | ||
|
||
$ Pr(X_i = 1) = \frac{3}{16} + \frac{3}{16} $ | ||
|
||
$ Pr(X_i = 1) = \frac{6}{16} $ | ||
|
||
$ Pr(X_i = 1) = \frac{3}{8} $ | ||
|
||
The probability that each element in the string is non-zero is the probability that each element is different | ||
|
||
$ \frac{3}{8} \cdot \frac{3}{8} \cdot \text{...} \cdot \frac{3}{8} $ | ||
|
||
$ = {( \frac{3}{8})}^{77} $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/content/questions/comp2804/2018-winter-final/17/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
Let S be the total number of ways to choose a permutation from a set of size $2n$: $2n!$ | ||
|
||
For the first element and the last element in the permutation are even integers, we have to choose 2 even numbers. There are two ways to rearrange the 2 even numbers: $\binom{n}{2} \cdot 2$ | ||
|
||
For the remaining positions in the permutation, we have $(2n-2)!$ ways to rearrange these numbers: $(2n-2)!$. | ||
|
||
$Pr(A) = \frac{|A|}{|S|} = \frac{\binom{n}{2} \cdot 2 \cdot (2n-2)!}{2n!} = \frac{ \frac{n!}{2!(n-2)!} \cdot 2 \cdot (2n-2)!}{2n!} = \frac{n(n-1)}{2n(2n-1)} = \frac{n-1}{2(2n-1)}$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
src/content/questions/comp2804/2018-winter-final/19/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
Let $X_i$ be 1 if $b_i \cdot b_{i+1} = 0$ and 0 otherwise. This only happens if a pair of consecutive bits contain a 0. | ||
|
||
$ Pr(X*i = 1) = Pr{(b_i = 0 \text{ and } b*{i+1} = 1)} + Pr{(b*i = 1 \text{ and } b*{i+1} = 0)} + Pr{(b*i = 0 \text{ and } b*{i+1} = 0)} $ | ||
$ Pr(X*i = 1) = \frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot \frac{1}{2} $ | ||
|
||
$ Pr(X\*i = 1) = \frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot \frac{1}{2} + \frac{1}{2} \cdot \frac{1}{2} $ | ||
|
||
$ Pr(X_i = 1) = \frac{1}{4} + \frac{1}{4} + \frac{1}{4} $ | ||
|
||
$ Pr(X_i = 1) = \frac{3}{4} $ | ||
|
||
Since the last bit has no bit after it, we only take into account the first $n-1$ bits | ||
|
||
$ \mathbb{E}(X) = \sum*{k=1}^{n-1} 1 \cdot Pr(X*i = 1) $ | ||
$ \mathbb{E}(X) = \sum*{k=1}^{n-1} \frac{3}{4} $ | ||
|
||
$ \mathbb{E}(X) = \sum\*{k=1}^{n-1} \frac{3}{4} $ | ||
|
||
$ \mathbb{E}(X) = \frac{3}{4} \cdot (n-1) $ | ||
|
||
$ \mathbb{E}(X) = \frac{3(n-1)}{4} $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
src/content/questions/comp2804/2018-winter-final/20/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
Let $X_i$ be 1 if $C$ is not at position 1 and 2 if $C$ is at position 1 | ||
$ Pr(X*i=1) = Pr(\text{$B_i$ is at position 1}) = \frac{1}{n+1} $ | ||
|
||
$ Pr(X\*i=1) = Pr(\text{$B_i$ is at position 1}) = \frac{1}{n+1} $ | ||
|
||
$ Pr(X_i=2) = Pr(\text{$C$ is at position 1}) = \frac{1}{n+1} $ | ||
|
||
$ \mathbb{E}(X) = \sum*{k=2}^{n+1} 1 \cdot Pr(X*i=1) + 2 \cdot Pr(X_i=2) $ | ||
$ \mathbb{E}(X) = \sum*{k=2}^{n+1} 1 \cdot \frac{1}{n+1} + 2 \cdot \frac{1}{n+1} $ | ||
|
||
$ \mathbb{E}(X) = \sum\*{k=2}^{n+1} 1 \cdot \frac{1}{n+1} + 2 \cdot \frac{1}{n+1} $ | ||
|
||
$ \mathbb{E}(X) = \sum\_{k=2}^{n+1} \frac{1}{n+1} + \frac{2}{n+1} $ | ||
|
||
$ \mathbb{E}(X) = (n+1-2) \cdot ( \frac{1}{n+1} + \frac{2}{n+1})$ | ||
|
||
$ \mathbb{E}(X) = \frac{n+1-2+1+2}{n+1} $ | ||
|
||
$ \mathbb{E}(X) = \frac{n+2}{n+1} $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/content/questions/comp2804/2018-winter-final/22/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
In the algorithm, the value of $k$ keeps increasing if the two dice rolls are different. Theoreticaly, this algorithm can go on forever, until the two dice rolls are the same. | ||
|
||
This is an example of the Geometric Distribution. | ||
|
||
Let $p$ represent the probability of not ending the recursive algorithm. Using the formula for the expected value for Geometric Distribution we get: | ||
|
||
$E(X) = \frac{1}{p} = \frac{1}{ \frac{5}{6}} = \frac{6}{5}$ |
5 changes: 5 additions & 0 deletions
5
src/content/questions/comp2804/2018-winter-final/23/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
To prove that this statement is false, we need to provide a counterexample: | ||
|
||
Let X, Y, Z all represent the random variables where $X, Y, Z = 1$ if a coin toss is heads and $X, Y, Z = 0$ if a coin toss is tails. | ||
|
||
The expected value of $X, Y, Z$ in this case (as\suming that $\frac{1}{2}$ chance of hitting heads or tails) is: $E(X) = E(Y) = E(Z) = 0 \cdot \frac{1}{2} + 1 \cdot \frac{1}{2} = \frac{1}{2}$. | ||
|
||
This means that the $min(E(X), E(Y), E(Z) = min( \frac{1}{2}, \frac{1}{2}, \frac{1}{2}) = \frac{1}{2}$ is $\frac{1}{2}$. | ||
|
||
For the LHS, we need to calculate the expected value for $min(X, Y, Z)$. There are only two possible values in this case: $min(X, Y, Z) = 0$ and $min(X, Y, Z) = 1$ | ||
|
||
<ul> | ||
<li> Pr(min(X, Y, Z) = 1) = every coin has to come up with a heads = $( \frac{1}{2})^{3} = \frac{1}{8}$ | ||
<li> Pr(min(X, Y, Z) = 0) = 1 - Pr(min(X, Y, Z) = 1) = $1 - \frac{1}{8} = \frac{7}{8}$ | ||
<li> $E(min(X, Y, Z)) = 0 \cdot Pr(min(X, Y, Z) = 0) + 1 \cdot Pr(min(X, Y, Z) = 1) = 0 \cdot \frac{7}{8} + 1 \cdot ( \frac{1}{8}) = \frac{1}{8}$. | ||
</ul> | ||
|
||
Since $E(min(X, Y, Z)) = \frac{1}{8}$ and $min(E(X), E(Y), E(Z)) = \frac{1}{2}$, the two are not the same, so the statement is false. |
39 changes: 28 additions & 11 deletions
39
src/content/questions/comp2804/2018-winter-final/24/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
Let S be the set of all possibilities = $ |S| = 8^{3} $ | ||
|
||
Let A be the set of all possibilities where a student gets exactly 2 ciders | ||
|
||
To get exactly 2 ciders, a student has to have 2 ciders and 1 beer. There are 3 ways to get 2 ciders and a beer: $CBC, BCC, CCB$. | ||
|
||
<ul> | ||
<li> Number of ways for combination $CBC$: $\binom{5}{1} \cdot \binom{3}{1} \cdot \binom{5}{1} = 5^2 \cdot 3$ | ||
<li> Number of ways for combination $BCC$: $\binom{3}{1} \cdot \binom{5}{1} \cdot \binom{5}{1} = 5^2 \cdot 3$ | ||
<li> Number of ways for combination $CCB$: $\binom{5}{1} \cdot \binom{5}{1} \cdot \binom{3}{1} = 5^2 \cdot 3$ | ||
</ul> | ||
Now, we can sum | ||
$ Pr(A) = Pr( CBC ) + Pr( BCC ) + Pr( CCB ) $ | ||
$ Pr(A) = (5^2 \cdot 3) + (5^2 \cdot 3) + (5^2 \cdot 3) $ | ||
$ Pr(A) = 3 \cdot \frac{5^2 \cdot 3}{8^3} $ | ||
$ Pr(A) = \frac{3^2 \cdot 5^2}{8^3}$ | ||
|
||
Now, we can sum | ||
|
||
$ Pr(A) = Pr( CBC ) + Pr( BCC ) + Pr( CCB ) $ | ||
|
||
$ Pr(A) = (5^2 \cdot 3) + (5^2 \cdot 3) + (5^2 \cdot 3) $ | ||
|
||
$ Pr(A) = 3 \cdot \frac{5^2 \cdot 3}{8^3} $ | ||
|
||
$ Pr(A) = \frac{3^2 \cdot 5^2}{8^3}$ | ||
|
||
Let $X_i$ be an indicator random variable where: | ||
|
||
$ 1 \text{ if a student gets exactly 2 ciders} $ | ||
|
||
$ 0 \text{ otherwise} $ | ||
$ Pr(X*i = 1) = Pr(A) = \frac{3^2 \cdot 5^2}{8^3}$ | ||
$ \mathbb{E}(X) = \sum*{k=1}^{16} 1 \cdot Pr(X*i = 1) $ | ||
$ \mathbb{E}(X) = \sum*{k=1}^{16} \frac{3^2 \cdot 5^2}{8^3} $ | ||
$ \mathbb{E}(X) = 16 \cdot \frac{3^2 \cdot 5^2}{8^3} $ | ||
$ \mathbb{E}(X) = 2^4 \cdot \frac{3^2 \cdot 5^2}{8^3} $ | ||
$ \mathbb{E}(X) = \frac{2^4 \cdot 3^2 \cdot 5^2}{8^3} $ | ||
|
||
$ Pr(X\*i = 1) = Pr(A) = \frac{3^2 \cdot 5^2}{8^3}$ | ||
|
||
$ \mathbb{E}(X) = \sum*{k=1}^{16} 1 \cdot Pr(X*i = 1) $ | ||
|
||
$ \mathbb{E}(X) = \sum\*{k=1}^{16} \frac{3^2 \cdot 5^2}{8^3} $ | ||
|
||
$ \mathbb{E}(X) = 16 \cdot \frac{3^2 \cdot 5^2}{8^3} $ | ||
|
||
$ \mathbb{E}(X) = 2^4 \cdot \frac{3^2 \cdot 5^2}{8^3} $ | ||
|
||
$ \mathbb{E}(X) = \frac{2^4 \cdot 3^2 \cdot 5^2}{8^3} $ | ||
|
||
$ \mathbb{E}(X) = 2^4 \cdot 3^2 \cdot \frac{5^2}{8^3} $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/content/questions/comp2804/2018-winter-final/5/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
The answer is C, and I will show how the expression in the question shows the number of ways to choose a 2-element subset from a set consisting of m + n elements: | ||
|
||
From a set of $m + n$ elements, we can form 2-element subsets in 3 different ways: | ||
|
||
<ul> | ||
<li> Choose 2 elements from the $m$ set: there are $\binom{m}{2}$ ways to do this | ||
<li> Choose 2 elements from the $n$ set: there are $\binom{n}{2}$ ways to do this | ||
<li> Choose 1 element from the $m$ set and 1 element from the $n$ set: there are $\binom{m}{1} \cdot \binom{n}{1} = m \cdot n$ | ||
</ul> | ||
|
||
Now, if we apply the Sum Rule to all of these cases above, we get $\binom{m}{2} + \binom{n}{2} + m \cdot n$, which matches the expression above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/content/questions/comp2804/2018-winter-final/8/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
The first character can be any of the 4 characters: 4 | ||
|
||
The second character can be any of the 3 characters that are not the first character: 3 | ||
|
||
The third character can be any of the 3 characters that are not the second character: 3 | ||
|
||
... | ||
|
||
The nth character can be any of the 3 characters that are not the $(n-1)$th character: 3 | ||
|
||
$= 4 \cdot 3^{n-1} $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters