Solving a recurrence: T(n)=3T(n/2)+n

后端 未结 4 1777
星月不相逢
星月不相逢 2021-01-07 05:09

I need to Find the solution of the recurrence for n, a power of two if T(n)=3T(n/2)+n for n>1 and T(n)=1 otherwise.

using substitution of n=2^m,S(

4条回答
  •  执念已碎
    2021-01-07 05:36

    The problems like this can be solved using Masters theorem.

    In your case a = 3, b = 2 and f(n) = n.

    So c = log_b(a) = log_2(3), which is bigger than 1, and therefore you fall into the first case. So your complexity is:

    O(n^{log_2(3)}) = O(n^{1.58})

提交回复
热议问题