How to solve this recurrence relation: T(n) = 4*T(sqrt(n)) + n

前端 未结 4 989
我在风中等你
我在风中等你 2020-12-22 07:46

I know how to solve the recurrence relations using Master Method. Also I\'m aware of how to solve the recurrences below:

T(n) = sqrt(n)*T(sqrt(n)) + n

T(n) =

4条回答
  •  猫巷女王i
    2020-12-22 08:28

    I'm having trouble in solving this one: T(n) = 4*T(sqrt(n)) + n

    EDIT: Here n is a power of 2

    This edit is important. So lets say that the recurrence stops at 2.

    So the question now is how deep the recursion tree is. Well, that is the number of times that you can take the square root of n before n gets sufficiently small (say, less than 2). If we write

    n = 2lg n

    then on each recursive call n will have its square root taken. This is equivalent to halving the above exponent, so after k iterations we have that

    n1/(2k) = 2lg n/(2k)

    We want to stop when this is less than 2, giving

    2lg n/(2k) = 2

    lg n/(2k) = 1

    lg n = 2k

    lg lg n = k

    So after lg lg n iterations of square rooting the recursion stops. (source)

    For each recursion we will have 4 new branches, the total of branches is 4 ^ (depth of the tree) therefore 4^(lg lg n).

    EDIT:

    enter image description here

    Source

提交回复
热议问题