# Review 3 * Hajin Ju, 2024062806 ## Problem 1 Write `O` if an entry is true or `X` otherwise. ### Solution 1 | | $$O(n \lg n)$$ | $$\Omega(n \lg n)$$ | $$\Theta(n\lg n)$$ | | :-----------: | :------------: | :-----------------: | :----------------: | | $$\lg n$$ | O | X | X | | $$n$$ | O | X | X | | $$n \lg n$$ | O | O | O | | $$n \lg^2 n$$ | X | O | X | | $$n^2$$ | X | O | X | ## Problem 2 Show $3n + 1 = O(n^2)$ by the definition of $O$. ### Solution 2 A function $f(n) = O(g(n))$ if there exist constants $c\geq 0$ and $n_0\geq 0$, s.t. $$n \geq n_0 \Rightarrow \leq |f(n)| \leq c |g(n)|$$ --- let $g(n) = n^2$ let $f(n) = 3n+1$ suppose $c=4,\, n_0 = 1$ and then, for all $n \geq 1 \to |3n+1| \leq 4n^2$ therefore, $3n+1 = O(n^2)$ by the above definition. ## Problem 3 Write asymptotic notations that satisfy each relation and explain why. 1. Transitivity 2. Reflexivity 3. Symmetry ### Solution 3 1. Transitivity * $O$ is transitive because $f(n) = O(g(n))$ and $g(n) = O(h(n))$ implies $f(n) = O(h(n))$ there must exists $n_0\geq 0$, s.t. $n \geq n_0 \Rightarrow f(n) \leq c_0 g(n) \leq c_1 c_0 h(n)$ * $\Omega$ is transitive because $f(n) = \Omega(g(n))$ and $g(n) = \Omega(h(n))$ implies $f(n) = \Omega(h(n))$ there must exists $n_0\geq 0$, s.t. $n \geq n_0 \Rightarrow f(n) \geq c_0g(n) \geq c_1 c_0 h(n)$ * $\Theta$ is transitive because $f(n) = \Theta(g(n))$ and $g(n) = \Theta(h(n))$ implies $f(n) = \Theta(h(n))$ $$f(n) = O(h(n)) \land f(n) = \Omega(h(n))$$ 2. Reflexivity * $O$ is reflexive because $f(n) = O(f(n))$ where $c=1$ * $\Omega$ is reflexive because $f(n) = \Omega(f(n))$ where $c=1$ * $\Theta$ is reflexive * because $f(n) = \Theta(f(n))$ 3. Symmetry * $O$ is **not** symmetric because $f(n) = O(g(n))$ does not imply $g(n) = O(g(n))$ for example, $n = O(n^2)$ cannot imply $n^2 = O(n)$ * $\Omega$ is **not** symmetric because $f(n) = \Omega(g(n))$ does not imply $g(n) = \Omega(g(n))$ for example, $n^2 = \Omega(n)$ cannot imply $n = \Omega(n^2)$ * $\Theta$ is symmetric because $f(n) = \Theta(g(n))$ implies $g(n) = \Theta(g(n))$