Sum of functions is big Oh

399 Views Asked by At

I want to show that if $$ d(n) \in O(f(n)) \ \Rightarrow d(n) \le c_1*f(n) \\ e(n) \in O(g(n))\Rightarrow e(n) \le c_2 *g(n) \\ $$ then $$ d(n) +e(n) \in O(f(n)+g(n)) $$ Can I say that (A) $$ d(n) +e(n) \le (c_1*f(n))+(c_2*g(n)) \ \forall \ n\ge n_1 +n_2 \text{ and } c_1,c_2 >0 $$ or (B) $$ 2*\max(d(n), e(n)) \le c*(g(n)+f(n)) \ \forall \ n \ge \max(n_1, n_2) \text{ and } c\ge2 $$ Is either of the two considered a proof?

2

There are 2 best solutions below

2
On BEST ANSWER

For $n\ge n_1,n_2$, we obviously have

$$d(n)+e(n)\le c_1f(n)+c_2g(n)\le\max(c_1,c_2)(f(n)+g(n)),$$ which establishes the claim, in a constructive way.

0
On

The option which is more correct is (B): however, for the sake of rigour, putting $c=\max\{c_1,c_2\}$, the proof should be as below $$ \begin{split} d(n)+e(n)&\le c_1\cdot f(n)+c_2\cdot g(n)\\ &\le c\cdot f(n) +c\cdot g(n)\\&=c\cdot\big(f(n)+g(n)\big)\\ &\Updownarrow\\ d(n)+e(n) &\in O\big(f(n)+g(n)\big) \end{split}\quad \forall n\in \Bbb N $$