does $f(n) \neq O(g(n))$ implies $g(n)=O(f(n))$

138 Views Asked by At

Im pretty sure it doesn't, but how can I be sure?

Was thinking by using

$$f(x) = \sin(x) + 2$$ and $$g(x) = \cos(x) + 2$$

Thanks!`

2

There are 2 best solutions below

0
On

If you mean $\sin(x)+2$ and $\cos(x)+2$, then those functions are big-O of each other.

A true counterexample would be, $f(n)=1+n^2\sin(n)^2$ and $g(n)=n$.

0
On

No.

Let $f(n) = 1$ if $n$ is even and $n$ if $n$ is odd and let $g(n) = 1$ if $n$ is odd and $n$ if $n$ is even.

Then $f(n)/g(n) = n$ if $n$ is odd and $f(n)/g(n) = 1/n$ if $n$ is even.