Homework 3
Document last modified:
Prove max(f(n), g(n)) is Q(f(n) + g(n))
That means determine two constants c1 and c2 such that:
c1(f(n) + g(n)) ≤ max(f(n), g(n)) ≤ c2(f(n) + g(n))
To clarify max(f(n), g(n)) function, define a function h(n) = max(f(n), g(n)):
æ f(n) if (fn) ³ g(n)
h(n) = í
è g(n) if f(n) < g(n)
Need to find:c1 and c2
c2: To prove max(f(n), g(n)) ≤ c2(f(n) + g(n))
Since f (n) and g(n) are asymptotically nonnegative, there exists f(n) ≥ 0 and g(n) ≥ 0 for all n ≥ n0.
Thus for n ≥ n0:
f(n)+g(n)≥f(n)≥0
f(n)+g(n)≥g(n)≥ 0
Since for any particular n, h(n) = max(f(n), g(n)) is either f(n) or g(n)
0 ≤ h(n) = max(f(n), g(n)) ≤ c2(f(n) + g(n)) for all n ≥ n0
holds for c2=1 in definition of Q.
c1: To prove c1(f(n) + g(n)) ≤ max(f(n), g(n)) = h(n)
Is 2n+1 = O(2n)?
To solve, try to determine one constant c such that:
2n+1 ≤ c2n
If you can find that constant c, then answer true, but if c turns out to not be constant, i.e., it depends on n (which isn’t constant), then it’s false.
T(1) = 1
T(n) = T(n/3) + 1 for n>1
Hint: Use backward substitution.
Where ad>0, and k a constant.
If k ³ d, then p(n) = O(nk)
Must determine c and n0 such that p(n) ≤ cnk for n > n0
Expand out p(n), the summation, in the inequality, do some algebra to simplify and then let n go to infinity for k=d and k>d.
Show the conjecture is false: f(n)+g(n) = Q( min( f(n), g(n) ) )
Hint: Give an example that contradicts: f(n)+g(n) = Q( min( f(n), g(n) ) )
Turn in