Knowee
Questions
Features
Study Tools

Consider the following recurrence relation for a function T(n):T(n) = 3T(n/2​) + nUse the recursion tree method to determine the time complexity of T(n)

Question

Consider the following recurrence relation for a function T(n):T(n) = 3T(n/2​) + nUse the recursion tree method to determine the time complexity of T(n)

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, let's solve this step by step:

  1. First, let's draw the recursion tree for the given recurrence relation T(n) = 3T(n/2) + n. The root of the tree is T(n) and it has 3 children T(n/2), T(n/2), and T(n/2). Each of these children will have their own children and so on.

  2. The cost at the root of the tree is n. The cost at the next level is 3*(n/2) because there are 3 nodes each with cost n/2. The cost at the third level is 3^2*(n/4) because there are 3^2 nodes each with cost n/4. This pattern continues for all levels of the tree.

  3. The height of the tree is log base 2 of n because each level we are dividing n by 2.

  4. The total cost of the tree is the sum of the costs at all levels. This is n + 3*(n/2) + 3^2*(n/4) + ... + 3^(log base 2 of n)(n/n) = n(1 + 3/2 + (3/2)^2 + ... + (3/2)^(log base 2 of n)).

  5. The sum inside the parentheses is a geometric series with ratio 3/2 and log base 2 of n terms. The sum of a geometric series is (1 - r^k)/(1 - r) where r is the ratio and k is the number of terms. Substituting r = 3/2 and k = log base 2 of n we get (1 - (3/2)^(log base 2 of n))/(1 - 3/2).

  6. Simplifying the above expression we get (2^n - 3^n)/(-1/2) = 23^n - 22^n.

  7. Therefore, the time complexity of T(n) is O(3^n) because the term 3^n dominates 2^n for large n.

This problem has been solved

Similar Questions

Consider the following recurrence relation: T(n)=3T(n/3)+n2/3,T(1)=1,T(0)=0 What is the complexity of T(n)? Options : Θ(n) Θ(nlogn) Θ(n^2/3) Θ(n^1.5)

what's the Big-Oh complexity for recursive relations T(n)=T(n-1)+n

What is the tight bound using Big-Theta notation for the time complexity of the following recurrence relation: T(n) = 3T(n/2) + 1 when the Master Theorem is used? Θ(n^(log2(3))) Θ(n^(log3(2))) Θ(nlogn) Θ(log2(n))+O(1)

The recurrence relation that arises in relation with the complexity of binary search is:1.T(n) = T(n / 2) + n2.T(n) = T(n / 2) + log n3.T(n) = 2T(n/ 2) + k , where k is constant4.T(n) = T(n / 2) + k

Practice the Substitution method, recursive tree method, and master theorem on the following:i) F(n)=n∗F(n−1)ii) T(n) = 1, when n=1=1+T(n-1) when n>1iii) Fn=Fn−1+Fn−2.iv) T(n)=4T(n/2)+n^2v) T(n)=2T(n/2)+n

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.