Question

Show that $O(\text{max}\{f(n),g(n)\})=O(f(n)+g(n))$

Can I keep the same constant $c$ in each of the cases?

Consider two cases: $$1)f(n)>g(n);O(\text{max}\{f(n),g(n)\})⇒O(f(n))\Rightarrow d(n) ≤c⋅f(n);c>0$$ $$2)f(n)≤g(n);O(\text{max}\{f(n),g(n)\})⇒O(g(n))\Rightarrow e(n)≤c⋅g(n);c>0$$ Combining the 2 cases yields: $$d(n)+e(n)≤c⋅f(n)+c⋅g(n)$$ $$d(n)+e(n)≤c⋅(f(n)+g(n))$$ Which is definition of $O(f(n)+g(n))$

Was it helpful?

Solution

I guess the proof is fine except for the fact that you have used same costant in two different eqns. Even if you use(and you must use, because the constant you choose is arbitrary) two different conts say c1 and c2, the solution will imply the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top