(ii) Solve the following recurrence relation using Recurrence Tree Method.
T(n) ={1 if n = 1
T(n/2 ) + n if n > 1}
Show all the steps.
The recursion tree for the given recurrence relation is-
T(n)−d↓T(n2)−d↓T(n4)−d↓T(1)−d↓T(n)- d\\ \downarrow \\ T(\dfrac{n}{2})-d \\\downarrow\\ T(\dfrac{n}{4})-d \\\downarrow\\ T(1)-d \downarrowT(n)−d↓T(2n)−d↓T(4n)−d↓T(1)−d↓
we go like n,n2,n4,n8...1n,\dfrac{n}{2},\dfrac{n}{4},\dfrac{n}{8}...1n,2n,4n,8n...1
or 2k=n,k=log2n2^k=n, k=log_2n2k=n,k=log2n
So we sum d+d+d.. for log2nlog_2nlog2n terms complexity =0(log2n)=0(log2n)=0 (log_2n)=0(log_2n)=0(log2n)=0(log2n)
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments