Proof that $O(n^2 + n + a)$ is a subset of $O(n^2)$

623 Views Asked by At

I'm new to the Big-O Notation and couldn't find any question that covers my problem of understanding. From my intuition, it is clear that for $n\rightarrow+\infty$, that $n^2+n+a$ "behaves" like $n^2$, so any function that has an upper bound in the form of $n^2+n+a$ also has an upper bound of the form $n^2$, but the $n_0$ and $c$ will be different.

Unfortunately, I fail to proof formally that this is correct. If somebody could provide a proof using the Big-O definition, I would be glad.

1

There are 1 best solutions below

10
On BEST ANSWER

Let $f(n) \in \mathcal O(n^2 +n+a)$ with $$f(n) \le c_0 (n^2 +n+a)\quad\forall n\ge n_0$$

Now chose $n_1 = \max(a, 2, n_0)$ such that $n_1^2 \ge n_1 +a$. Then $$f(n) \le c_0 (n^2 + n + a) = c_0 n^2 + c_0 (n+a) \le c_0 n^2 + c_0 n^2 = 2c_0 n^2 \quad\forall n \ge n_1$$ Thus $f(n) \in \mathcal O(n^2)$ for constants $n_1$ and $c_1 := 2c_0$.

More generally you can prove that $f\in\mathcal O(g)$ and $g\in \mathcal O(h)$ implies $f\in\mathcal O(h)$ as well as $\mathcal O(g) = \mathcal O(f + g)$.