Reccurrence T(n) = T(n^(1/2)) + 1

ftsk33 picture ftsk33 · Mar 3, 2012 · Viewed 26.5k times · Source

I've been looking at this reccurrence and wanted to check if I was taking the right approach.

T(n) = T(n^(1/2)) + 1
= T(n^(1/4)) + 1 + 1
= T(n^(1/8)) + 1 + 1 + 1
...
= 1 + 1 + 1 + ... + 1 (a total of rad n times)
= n^(1/2)

So the answer would come to theta bound of n^(1/2)

Answer

Salvador Dali picture Salvador Dali · Dec 14, 2015

Here is how you can find the answer without any hints, just by using math.

Start unrolling the recursion: enter image description here.

The recursion will at some point stop, so we have to find a reasonable stopping point. Trying 0, 1, 2, you can see that 2 looks good, because you can easily solve the equation: enter image description here.

Solving it, you get enter image description here.

So the recursion will continue log(log(n)) times and this is your time complexity.

P.S. a little bit harder recurrence was solved here.