Neglecting constants in big O notation

244 Views Asked by At

I'm just starting to learn big O notation and there's one thing in particular that bothers me. Say $f(n) = O(g(n)+c))$, where c is a constant. To my understanding, $f(n)$ can just be represented as $O(g(n))$ because constant terms don't really matter as n approaches infinity. However, are there functions where this is not necessarily true?

1

There are 1 best solutions below

2
On BEST ANSWER

The constant $c$ can be absorbed by $g(n)$ if there is a $\delta > 0$ and an $n_0$ such that $g(n) \geqslant \delta$ for all $n \geqslant n_0$. If that is not the case, the constant cannot be absorbed by $g(n)$. If you have $g(n) \to 0$ for $n \to \infty$, then the $g(n)$ part can be absorbed by the constant, but if $g$ takes large as well as small values for large $n$, for example

$$g(n) = n^{(-1)^n},$$

then neither can $g(n)$ absorb the constant $c$, nor can $c$ absorb $g(n)$.

Such a $g$ is however not something one usually has in big-Oh estimates. Usually, one uses functions that have a regular monotonic growth or decay to bound the values of the other function.