Search code examples
algorithmcomputer-sciencegraph-algorithmrecurrence

How To Solve Recurrence Relation with a quadratic term


I'm trying to solve this recurrence relation. Here's what I've attempted so far, but I think I'm wrong. I would really appreciate some guidance.

This is the recurrence relation I am trying to solve:- 2T(n^1/2) + C

T(n) = 2T(n^1/2) + C
2((2T(n^1/4)+C) + C
>> 4T(n^1/16) + 3C
>> 8T(n^1/256) + 6C

So I can formulate it into this algebraic expression:-

 (2^k)T(n^(1/2^k)) + 2k

So to solve the recurrence relation, I simply say

n^(1/(2^k)) = 1
Therefore:-   2k = log (base n) 1
But this makes k = 0....

I don't think this is correct. Please advise me, I'd be delighted to get some assistance!


Solution

  • My try. (warn: I'm not sure substitution is the right thing to do here. Let's give a shot.)

    Let's say that T(x) = 1 for x < 2

    with T(1) is a no-go (see my comment), so maybe we can try to compute T(2)

    T(2) = 2 * T(sqrt(2)) + C = 2 + C
    

    now we search for k such that n^(1/2^k) = 2 + C

    1/(2^k) = log_n(2 + C)       [base n log]
    1/log_n(2 + C) = 2^k
    log_(2 + C) n = 2^k          [1 / log_a b = log_b a]
    lg n / lg (2 + C) = 2^k      [change-of-base]
    c2 lg n = 2^k            [since lg (2 + C) is fixed we put c2 = 1 / lg (2 + C)]
    k = lg (c2 * lg n) = (lg c2) + lg lg n
    k = c3 + lg lg n         [since lg c2 is fixed]
    

    now we substitute back k into T(N) = 2^k + 2k and we find

    T(n) = 2^c3 * lg n + 2*c3 + lg lg n
    

    now if we put togheter

    T(n) = c1 lg n + c2 lg lg n
    

    where c1 and c2 are fixed and different from the ones we used above.