Processing math: 100%

Problem 4-1

Recurrence examples

Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. Assume that T(n) is constant for n2. 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)4cn4n48cn4

holds for 18c1. 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)7n107107cn1049n1007cn1049n70cn

holds for 4970c<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)2cn27n29cn2

holds for 79c<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.80.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(n2)+n2.

This recurrence has a height of n2 and adding up the costs for each level of the ‘tree’:

T(n)=cn2+c(n2)2+c(n4)2+=cn/2i=0(n2i)2=cn/2i=0(n24ni+4i2)=c(n/2i=0n2n/2i=04ni+n/2i=04i2)=Θ(n3)Θ(n2)+Θ(n3)=Θ(n3)