Recurrence examples
Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. Assume that T(n) is constant for n≥2. Make your bounds as tight as possible, and justify your answers.
a. T(n)=2T(n/2)+n4.
a=2, b=2 and f(n)=n4.
Case 1 does not apply since f(n)=O(nlog22−ϵ)⟹ϵ=−3.
Case 2 does not apply since f(n)≠Θ(nlog22).
Case 3 applies since f(n)=Ω(nlog22+ϵ)=Ω(n1+3) and
a(f(n/b))≤cf(n)2(n2)4≤cn4n48≤cn4holds for 18≤c≤1. Thus the solution to the recurrence is T(n)=Θ(f(n))=Θ(n4).
b. T(n)=T(7n/10)+n.
a=1, b=107 and f(n)=n.
Case 1 does not apply since f(n)=O(nlog10/71−ϵ)=O(n0−ϵ)⟹ϵ=−1.
Case 2 does not apply since f(n)≠Θ(nlog10/71).
Case 3 applies since f(n)=Ω(nlog10/71+ϵ)=Ω(n0+1) and
af(n/b))≤cf(n)7n10⋅710≤7cn1049n100≤7cn1049n70≤cnholds for 4970≤c<1. Thus the solution to the recurrence is T(n)=Θ(f(n))=Θ(n).
c. T(n)=16T(n/4)+n2.
a=16, b=4 and f(n)=n2.
Case 1 does not apply since f(n)=O(nlog416−ϵ)=O(n2−ϵ)⟹ϵ=0.
Case 2 applies since f(n)=Θ(nlog416)=Θ(n2). Thus the solution to the recurrence is T(n)=Θ(nlog416lgn)=Θ(n2lgn).
d. T(n)=7T(n/3)+n2.
a=7, b=3 and f(n)=n2.
Case 1 does not apply since f(n)=O(nlog37−ϵ)⟹ϵ<0.
Case 2 does not apply since f(n)≠Θ(nlog37).
Case 3 applies since f(n)=Ω(nlog37+ϵ)≈Ω(n1.77+.23) and
a(f(n/b))≤cf(n)7(n3)2≤cn27n29≤cn2holds for 79≤c<1. Thus the solution to the recurrence is T(n)=Θ(f(n))=Θ(n2).
e. T(n)=7T(n/2)+n2.
a=7, b=2 and f(n)=n2.
Case 1 applies since f(n)=O(nlog27−ϵ)≈O(n2.8−0.8). Thus the solution to the recurrence is T(n)=Θ(nlogba)=Θ(nlg7).
f. T(n)=2T(n/4)+√n.
a=2, b=4 and f(n)=√n.
Case 1 does not apply since f(n)=O(nlog42−ϵ)⟹ϵ=0.
Case 2 applies since f(n)=Θ(nlog42)=Θ(n0.5). Thus the solution to the recurrence is T(n)=Θ(nlog42lgn)=Θ(√nlgn).
g. T(n)=T(n−2)+n2.
This recurrence has a height of n2 and adding up the costs for each level of the ‘tree’:
T(n)=cn2+c(n−2)2+c(n−4)2+⋯=cn/2∑i=0(n−2i)2=cn/2∑i=0(n2−4ni+4i2)=c(n/2∑i=0n2−n/2∑i=04ni+n/2∑i=04i2)=Θ(n3)−Θ(n2)+Θ(n3)=Θ(n3)