Big-O notation always holds for this two functions?

6.8k Views Asked by At

For two any functions $f(n)$ and $g(n)$ always holds:

$f(n) = O(g(n))$ or $g(n) = O(f(n))$

Right?

Thanks

1

There are 1 best solutions below

3
On BEST ANSWER

That's not right. Let $f(x)=\cos x$ and $g(x)=\sin x$.

If $f(x)=O(g(x))$, then there would be some constant $C>0$ so that for $x$ sufficiently large, we would have $$\tag{1} |f(x)|\le C|g(x)|. $$

But for any positive integer $n$, we have $f(2n\pi)=1$ and $g(2n\pi)=0$. Since we can make $2n\pi$ arbitrarily large, this shows that $(1)$ cannot hold.

I'll leave it to you to show that $g(x)\ne O(f(x))$.