Big $O$ prove $2n^2 = O(n^2)$ and $2n^2 + n^2m = O(n^2 m)$

64 Views Asked by At

I'm stuck trying to prove a Big $O$ notation for two pieces of pseudocode I made.

I have analysed each and one comes out as $2n^2$ and the other is $2n^2 + n^2m$.

I have to prove the first is $O(n^2)$ and the second is (I believe) $O(n^2m)$ but I've got a little stuck.

So I believe I have to find a $C$ and $n_0$ such that $2n^2 \le c.n^2$ for all $n>n_0$

For the first if I choose $C=2$, then $2n^2 \le 2n^2$ for all $n>n_0$

And for the second one $2n^2 + n^2m \le 2n^2m$

Now apparently I can use a quadratic equation to prove this, but not sure where to go from here.

Can anyone help with this?

Thanks

1

There are 1 best solutions below

1
On
  1. $\frac{2n^2}{n^2}=2$. This gives $2n^2=O(n^2)$.

  2. $0 \le \frac{2n^2+n^2m}{n^2m}=\frac{1}{m}+1 \le 2$. This gives $2n^2+n^2m=O(n^2m)$.