2.3 KiB
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.
- Transitivity
- Reflexivity
- Symmetry
Solution 3
- Transitivity
-
Ois transitive becausef(n) = O(g(n))andg(n) = O(h(n))impliesf(n) = O(h(n))there must existsn_0\geq 0, s.t.n \geq n_0 \Rightarrow f(n) \leq c_0 g(n) \leq c_1 c_0 h(n) -
\Omegais transitive becausef(n) = \Omega(g(n))andg(n) = \Omega(h(n))impliesf(n) = \Omega(h(n))there must existsn_0\geq 0, s.t.n \geq n_0 \Rightarrow f(n) \geq c_0g(n) \geq c_1 c_0 h(n) -
\Thetais transitive becausef(n) = \Theta(g(n))andg(n) = \Theta(h(n))impliesf(n) = \Theta(h(n))
f(n) = O(h(n)) \land f(n) = \Omega(h(n))
- Reflexivity
Ois reflexive becausef(n) = O(f(n))wherec=1\Omegais reflexive becausef(n) = \Omega(f(n))wherec=1\Thetais reflexive- because
f(n) = \Theta(f(n))
- Symmetry
Ois not symmetric becausef(n) = O(g(n))does not implyg(n) = O(g(n))for example,n = O(n^2)cannot implyn^2 = O(n)\Omegais not symmetric becausef(n) = \Omega(g(n))does not implyg(n) = \Omega(g(n))for example,n^2 = \Omega(n)cannot implyn = \Omega(n^2)\Thetais symmetric becausef(n) = \Theta(g(n))impliesg(n) = \Theta(g(n))