Skip to content

Commit

Permalink
fixed equality signs
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLu2004 committed Jul 18, 2024
1 parent 871eb16 commit 6e8346c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1. **Base Case Analysis:** <br/>
For $ n = 0 $ or $ n = 1 $, $ FIB(n) $ is called directly and returns $ n $. <br/>
For $ n geq 2 $, the algorithm makes recursive calls to $ FIB(n-1) $ and $ FIB(n-2) $.
For $ n \geq 2 $, the algorithm makes recursive calls to $ FIB(n-1) $ and $ FIB(n-2) $.

2. **Recursive Call Analysis:**<br/>
To find the number of times $ FIB(4) $ is called in $ FIB(n) $, we analyze the recursive structure of $ FIB $.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ $ 0 = \frac{1}{3} \cdot \frac{1}{3} $

$ 0 = \frac{1}{9} $

$ 0 neq \frac{1}{9} $
$ 0 \neq \frac{1}{9} $

Therefore, $ G $ and $ B $ are not independent random variables.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ $ |A| = 2^{7} - 1 = 127 $

$ |B| = \binom{7}{7} = 1 $

Now, we can say for certain that $2^{n} - 1 geq \binom{n}{7} $
Now, we can say for certain that $2^{n} - 1 \geq \binom{n}{7} $
10 changes: 5 additions & 5 deletions src/content/questions/comp2804/2015-fall-midterm/14/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ JustinBieber$(8)$ = 2
JustinBieber$(16)$ = 3

<ul>
<li> $B(n) = \text{log } n - 1 \text{ for all } n geq 2. $ <br/>
<li> $B(n) = \text{log } n - 1 \text{ for all } n \geq 2. $ <br/>
$B(2) = 0$ <br/>
$B(4) = 1$
<li> $B(n) = \text{log } n - 1 \text{ for all } n geq 1. $ <br/>
<li> $B(n) = \text{log } n - 1 \text{ for all } n \geq 1. $ <br/>
$B(1) = -1$ <br/>
$B(2) = 0$ <br/>
$B(4) = 1$
<li> $B(n) = \text{log } n \text{ for all } n geq 2. $ <br/>
<li> $B(n) = \text{log } n \text{ for all } n \geq 2. $ <br/>
$B(2) = 1$ <br/>
$B(4) = 2$
<li> $B(n) = n - 2 \text{ for all } n geq 2. $ <br/>
<li> $B(n) = n - 2 \text{ for all } n \geq 2. $ <br/>
$B(2) = 0$ <br/>
$B(4) = 2$
</ul>

Thus, the correct answer is $B(n) = \text{log } n - 1 \text{ for all } n geq 2. $
Thus, the correct answer is $B(n) = \text{log } n - 1 \text{ for all } n \geq 2. $
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To determine the minimum value of $ m $ such that we can guarantee that a set $ S $ of $ m $ integers contains at least two elements whose difference is divisible by $ n $, we can use the Pigeonhole Principle.

Let $ k geq 1 $ be an integer. If $ k+1 $ or more objects are placed into $ k $ boxes, then there is at least one box containing two or more objects.
Let $ k \geq 1 $ be an integer. If $ k+1 $ or more objects are placed into $ k $ boxes, then there is at least one box containing two or more objects.

<ul>
<li> textbf{Residue Classes Modulo $ n $:} <br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Adding these two cases together, we obtain the recurrence relation:

$F(n,k) = F(n-1,k) + 2 \cdot F(n-1,k-1)$

This holds for all integers $ n geq 2 $ and $ k $ with $ 1 leq k leq n - 1 $.
This holds for all integers $ n \geq 2 $ and $ k $ with $ 1 \leq k \leq n - 1 $.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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$
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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
For $X$ and $Z$ to be independent, $Pr(X = x \cap Z = z) = Pr(X = x) \cdot Pr(Z = z)$, for all real numbers $x$ and $z$, by definition of independent random variables.

If we can find a counterexample, aka where $Pr(X = x \cap Z = z) neq Pr(X = x) \cdot Pr(Z = z)$, then we know the two are not independent.
If we can find a counterexample, aka where $Pr(X = x \cap Z = z) \neq Pr(X = x) \cdot Pr(Z = z)$, then we know the two are not independent.

Let $z = 0$, $x = 0$ and $y = 0$:

Expand All @@ -17,7 +17,7 @@ Now we check if LHS = RHS for the expression:
<li> $Pr(X = x \cap Z = z) = Pr(X = x) \cdot Pr(Z = z)$
<li> $Pr(X = 0 \cap Z = 0) = Pr(X = 0) \cdot Pr(Z = 0)$
<li> $\frac{1}{2} = \frac{1}{2} \cdot \frac{3}{4}$
<li> $\frac{1}{2} neq \frac{3}{8}$
<li> $\frac{1}{2} \neq \frac{3}{8}$
</ul>

Since LHS is not equal to RHS, then the events $X$ and $Z$ are not independent.
36 changes: 36 additions & 0 deletions src/content/questions/comp2804/equal_sign_slash_adder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import re

def find_phrases_without_backslash(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()

patterns = [
(r'(?<!\\)neq', 'neq'),
(r'(?<!\\)geq', 'geq'),
(r'(?<!\\)leq', 'leq')
]

lines_with_phrases = []
for index, line in enumerate(lines):
for pattern, phrase in patterns:
if re.search(pattern, line):
lines_with_phrases.append((index + 1, line.strip(), phrase))

return lines_with_phrases

def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file == 'solution.md':
file_path = os.path.join(root, file)
lines_with_phrases = find_phrases_without_backslash(file_path)
if lines_with_phrases:
print(f"File: {file_path}")
for line_number, line, phrase in lines_with_phrases:
print(f" Line {line_number}: {line} (contains '{phrase}')")
print()

if __name__ == "__main__":
directory = os.path.dirname(os.path.abspath(__file__))
process_directory(directory)

0 comments on commit 6e8346c

Please sign in to comment.