I'm confused as to how $f(n)$ can be $O(g(n))$, $\Theta (g(n))$ and $\Omega(g(n))$. Could someone help explain?
Note that $f(n) = O(g(n))$ iff $f(x) \leq c * g(x)$ for some constant $c$ and $x \geq x_{0}$. Big-Omega switches the inequality.
So if $f(n) = O(g(n))$ and $f(n) = \Omega(g(n))$, then we have $f(n) = c * |g(n)|$, which satisfies the definition of $\Theta(n)$.
To test this, consider $L = \lim_{n \to \infty} \frac{f(n)}{g(n)}$. If $0 < L < \infty$, then $f(n) = \Theta(g(n))$.
Copyright © 2021 JogjaFile Inc.
Note that $f(n) = O(g(n))$ iff $f(x) \leq c * g(x)$ for some constant $c$ and $x \geq x_{0}$. Big-Omega switches the inequality.
So if $f(n) = O(g(n))$ and $f(n) = \Omega(g(n))$, then we have $f(n) = c * |g(n)|$, which satisfies the definition of $\Theta(n)$.
To test this, consider $L = \lim_{n \to \infty} \frac{f(n)}{g(n)}$. If $0 < L < \infty$, then $f(n) = \Theta(g(n))$.