0% found this document useful (0 votes)
28 views2 pages

Anuj Thomas Mathew 1001237364

This document contains solutions to recurrence relation problems. It first shows that the recurrence T(n) = T(n-1) + n has a solution of Θ(n^2) using induction. It then shows that the recurrence T(n) = T(⌈n/2⌉) + 1 has a solution of O(lg n). Finally, it uses the master method to derive tight bounds for several recurrences: i) T(n) = 2T(n/4) + 1 is Θ(sqrt(n)), ii) T(n) = 2T(n/4) + sqrt(n) is Θ(sqrt(n)lg n),

Uploaded by

Anuj Mathew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Anuj Thomas Mathew 1001237364

This document contains solutions to recurrence relation problems. It first shows that the recurrence T(n) = T(n-1) + n has a solution of Θ(n^2) using induction. It then shows that the recurrence T(n) = T(⌈n/2⌉) + 1 has a solution of O(lg n). Finally, it uses the master method to derive tight bounds for several recurrences: i) T(n) = 2T(n/4) + 1 is Θ(sqrt(n)), ii) T(n) = 2T(n/4) + sqrt(n) is Θ(sqrt(n)lg n),

Uploaded by

Anuj Mathew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

4.

3-1:
Show that the solution of T(n) = T(n-1) + n is O(n^2).
Solution:
Applying recursion tree, T (n) = n (n 1) (n 2) 1 = n(n 1)/2 = (n 2 ).
We must prove the T (n) = (n 2 ) by induction. The inductive hypothesis is T (n) = cn2 for some
constant c > 0.
T (n) = T (n 1) + n
c(n 1)2 + n
= cn2 2cn + c + n
cn2
We can prove the T (n) = O(n 2 ) by similar arguments.

4.3-2:
Show that the solution of T (n) = T (n/2) + 1 is O(lg n)
Solution:
We guess that the solution is T (n) = O(lg n). We must prove that T (n) c lg n for appropriate c
> 0. We start by assuming that this bound holds for n/2, that is that T (n/2) c lg(n/2).
Substituting into the recurrence yields
T (n) c lg(n/2) + 1
c lg(n/2) + 1
= c lg n c lg2 + 1
= c lg n c + 1
= c lg n

if c 1

the last step holds as long as c 1. For the base case, it suffices to show that T (2) c lg 2 for
some c 1. T (2) = T (1) + 1 or T (2) = 2 assuming T (1) = 1. Thus T (2) c lg 2 if c 2.

4.5-1:
Use the master method to give tight asymptotic bounds for the following recurrences:
i)

T(n) = 2T(n/4) + 1
Solution:
For this recurrence, we have a = 2, b = 4, f (n) = 1, and thus we have that nlogba = nlog42.
Since f (n) = 1 = O(nlog42-), where = 0.2, we can apply case 1 of the master theorem
and conclude that the solution is T(n) = (nlog42) = (n1/2) = (sqrt(n)).

ii)

T(n) = 2T(n/4) + sqrt(n)


Solution:
For this recurrence, we have a = 2, b = 4, f (n) = sqrt(n), and thus we have that nlogba =
nlog42= n1/2 = sqrt(n). Since f (n) = ( ), we can apply case 2 of the master theorem and
conclude that the solution is T(n) = (sqrt(n)lg n).

iii)

T(n) = 2T(n/4) + n
Solution:
For this recurrence, we have a = 2, b = 4, f (n) = n, and thus we have that nlogba = nlog42.
Since f (n) = (nlog42+) , where = 0.2, we can apply case 3 of the master theorem if
we can show that the regularity condition holds for f (n).
To show the regularity condition, we need to prove that af (n/b) cf (n) for some
constant c < 1 and all sufficiently large n. If we can prove this, we can conclude that
T(n) = (f (n)) by case 3 of the master theorem.
Proof of the regularity condition:
af (n/b) = 2(n/4) = n/2 cf (n) for c = 0.7, and n 2.
So, we can conclude that the solution is T(n) = (f (n)) = (n).

iv)

T(n) = 2T(n/4) + n^2.


Solution:
For this recurrence, we have a = 2, b = 4, f (n) = n2 , and thus we have that nlogba =
nlog42. Since f (n) =(nlog42+) , where , we can apply case 3 of the master theorem if we
can show that the regularity condition holds for f (n). Proof of the regularity
condition: af (n/b) = 2 = (1/8) n2 c f (n) for c = 0.5, and n 4. So, we can conclude
that the solution is T(n) = (n2 ).

You might also like