Loading [MathJax]/jax/output/HTML-CSS/jax.js

Thursday, 8 June 2017

Chapter 3 Exercise 3.1-1, Introduction to Algorithms, 3rd Edition Thomas H. Cormen

3.1-1 Let f(n) and g(n) be asymptotically non-negative functions. Using the basic definition of Θ-notation, prove that max(f(n),g(n))=Θ(f(n)+g(n)).

Solution:

 To prove this, we have to show that there exists constants c1,c2,n0>0 such that 0c1(f(n)+g(n))max(f(n),g(n))c2(f(n)+g(n)) for all nn0.  As the functions are asymptotically non-negative, we can assume that for some n0>0,f(n)0 and g(n)0.
So Far
nn0 , f(n)+g(n)max(f(n),g(n))
Also note that,
f(n)max(f(n),g(n))
and g(n)max(f(n),g(n))f(n)+g(n)2max(f(n),g(n))12(f(n)+g(n))max(f(n),g(n))
Therefore, we can combine the above two inequalities as follows:
012(f(n)+g(n))max(f(n),g(n))(f(n)+g(n)) for nn0
So, max(f(n),g(n))=Θ(f(n)+g(n)) because there exists c1=12 and c2=1