Reccurrence T(n) = T(n^(1/2)) + 1
Asked Answered
C

2

8

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)

Cryoscopy answered 3/3, 2012 at 22:32 Comment(1)
Verify it with Wolphram Alpha.Boneset
B
9

hint: assume n = 22m or m = log2log2n, and you know 22m-1 * 22m-1 = 22m so, if you define S(m)=T(n) your S will be:

S(m) = S(m-1)+1 → S(m) = Θ(m) → S(m)=T(n) = Θ(log2log2n)

extend it for the general case.

In recursion like T(n) = T(n/2) + 1, in each iteration, we reduce the height of the tree to half. This leads to Θ(logn). In this case, however, we divide the input number by a power of two (not by two) so it turns out to be Θ(log log n ).

Brasilein answered 3/3, 2012 at 22:38 Comment(2)
so this means the the height of the recurrence tree is log log n?Cryoscopy
Yes exactly it is log log n (in base 2), in fact sqrt reduces value in power of 2 ( not two times).Brasilein
H
18

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.

Hacienda answered 14/12, 2015 at 1:1 Comment(3)
I like to study with your answers, I hope a day I will reach >10k points thereby working with you, sir. +1Pilar
For those having difficulty to catch loglogn part, the image can help you.Pilar
@snr Thanks for providing the handout. Cheers!Varices
B
9

hint: assume n = 22m or m = log2log2n, and you know 22m-1 * 22m-1 = 22m so, if you define S(m)=T(n) your S will be:

S(m) = S(m-1)+1 → S(m) = Θ(m) → S(m)=T(n) = Θ(log2log2n)

extend it for the general case.

In recursion like T(n) = T(n/2) + 1, in each iteration, we reduce the height of the tree to half. This leads to Θ(logn). In this case, however, we divide the input number by a power of two (not by two) so it turns out to be Θ(log log n ).

Brasilein answered 3/3, 2012 at 22:38 Comment(2)
so this means the the height of the recurrence tree is log log n?Cryoscopy
Yes exactly it is log log n (in base 2), in fact sqrt reduces value in power of 2 ( not two times).Brasilein

© 2022 - 2024 — McMap. All rights reserved.