If for functions $f, g$ we have $f = \mathcal{O}(g)$, then does $g = \mathcal{O}(f)?$ Explain why this is true or give an example showing it is false.


I believe this is false. if I take $g = n^3 +20 n +1$ then $f = \mathcal{O}(g) = \mathcal{n^3}$

But $g = \mathcal{n^3} = n^3 \neq n^3 +20n +1$

Is what I said correct? Any help will be appreciated.


Your stated belief is correct but your example isn't.

You should think of $\mathcal{O}$ as "grows no faster than (asymptotically)". Thus

$$ n^3 + 20n +1 = \mathcal{O}(n^3) $$ and $$ n^3 = \mathcal{O}(n^3+ 20n +1) $$ and $$ n = \mathcal{O}(n^3) $$ but $$ n^3 \ne \mathcal{O}(n). $$

Note: this isn't the formal definition of $\mathcal{O}$ but it is a good way to train your intuition.

| cite | improve this answer | |
  • $\begingroup$ Ok I see. Thanks! $\endgroup$ – CoolNewFriends Oct 2 '16 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.