Use a recursion tree for the following algorithms to find th

Use a recursion tree for the following algorithms to find the running time. T(n) = T(n - 1) + n T(n) = 2T(n/3) + n^2

Solution

2)2T(n/3)+n^2

Subproblem size at level i = n/3i

At level i:Cost of each node=c(n/3i)2   

# of nodes=2i Total cost= n2(2/9)i

h=height of the tree ->log3n

Therefore,T(n)=O(n2)

 Use a recursion tree for the following algorithms to find the running time. T(n) = T(n - 1) + n T(n) = 2T(n/3) + n^2Solution2)2T(n/3)+n^2 Subproblem size at le

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site