$f(n) = 2n^2 + n$
$g(n) = O(n^2)$
The question is to find the mistake in the following process:
$f(n) = O(n^2) + O(n)$
$f(n) - g(n) = O(n^2) + O(n) - O(n^2)$
$f(n)-g(n) = O(n)$
From how I understand it, Big-Oh represents the upper bound on the number of operations (when $n$ tends to very large value). So, the difference between an order of $n^2$ minus an order of $n^2$ should be negligible if $n$ is very large.
But the individual steps seem correct. It seems to me that the mistake is that when doing the minus with large values, the $O(n)$ will also get consumed.
I need clarification on whether I'm correct. If I'm not, then where is the mistake?
Hint
What if $g(n) = n^2$?
What does $f(n) - g(n)$ simplify to, and is it $O(n)$ or $O(n^2)$?
Clarification
With the above, we get $f(n) - g(n) = 2n^2 + n - n^2 = n^2 + n = O(n^2)$.
Remember that, by definition, $f(n) = O(n^p)$ means $f(n) \leq Cn^p$ for some constant $C$ if $n$ large enough. This still holds true for any general $g(n) = O(n^2)$.