Assume $f(n)=O(g(n))$ with $g(n)\geq 2$ for all $n$

29 Views Asked by At

Assume $f(n)=O(g(n))$ with $g(n)\geq2$ for all $n$

implies $f(n)+g(n)=O(g(n))$

the answer which teacher offer is false ,but I think it is true

this is my think

$f(n)=O(g(n))$ so $f(n)\leq c\cdot g(n)$ ,$f(n)+g(n)\leq (c+1)\cdot g(n)$

So $f(n)+g(n)=O(g(n))$

Am I wrong?

1

There are 1 best solutions below

0
On

You are correct, and just as a general rule of thumb when there is a linear combination of terms, for example $f(x)=ag(x)+bh(x)+...$ the only term that matters for the asymptotic is the leading(Largest) term. For example $3x^2+99x$ is $O(x^2)$

This can be used to show that you are right since $f(x)\sim O(g(x))$ by assumption and $g(x)\sim O(g(x))$ trivially then $f(x)+g(x)\sim O(g(x))$