4

Can anyone please help me with this question?

T(n)=T(n^(1/2)) + theta (lg lg n)

This is what I have done so far.

Let:

m = lg n
s(m)=s(m/2) + theta (lg m)

Applying the master theorem here

a=1 b=2
m^log 2 (1) = m^0 =1 

Now I'm stuck.

Jeff Schaller
  • 2,352
  • 5
  • 23
  • 38
aneena
  • 187
  • 1
  • 2
  • 13
  • `n^(1/2) = sqrt(n)`, and `(lg n) / 2 != sqrt(n)`, so your work so far seems wrong. Must you absolutely use the Master Method? – IVlad Mar 06 '15 at 18:52
  • @IVlad `lg(sqrt(n)) == lg(n)/2 == m / 2` (by definition). Isn't that correct? – Asad Saeeduddin Mar 06 '15 at 19:05
  • @Asad - yes, that's correct. But the OP has `T(sqrt(n))`, and I don't see how he got from that to `T(lg(sqrt(n)) = T(m / 2)`. It would be correct if he had `T(lg sqrt(n))`. – IVlad Mar 06 '15 at 19:09
  • @IVlad `T(√n)=s(lg√n)=s(m/2)`. I think you're overlooking the use of `s(m)=T(n)`. – Teepeemm Mar 06 '15 at 19:13

2 Answers2

1

You have:

a = 1, b = 2
f(m) = Ө(lg(m))

The second case of the master theorem applies if:

f(m) = Ө(m^c * lg^k(m))

where:

c = log_b(a)

Testing this out, we have:

f(m) = Ө(lg(m)) = Ө(m^0 * lg(m)) 
-> c = 0
-> c = log_b(a) = log_2(1) = 0

So the second case does apply. The solution to the recurrence is therefore:

T(m) = Ө(m^c * lg²(m)) = Ө(lg²(m))

Substituting m, we arrive back at

T(n) = Ө(lg²(lg(n)))
Asad Saeeduddin
  • 46,193
  • 6
  • 90
  • 139
  • Is a prerequisite however that `b>1` for the master theorem? – C.B. Mar 06 '15 at 18:56
  • 1
    I think that should be `T(m)=Ө(m^c * lg²(m)) = Ө(lg²(m))`, so that `T(n)=Ө(lg²(lg(n)))`. – Teepeemm Mar 06 '15 at 19:09
  • In class we have done it in a bit different way.Why did you multiply n^ log b(a) with f(N). Dont we just have to compare both? thats how we did in class – aneena Mar 06 '15 at 19:23
  • @aneena I'm not multiplying `log_b(a)` with `f(n)`. Which part of the answer are you referring to? In class, our professor covered the less general form of the algorithm where you compare `a` with `b` raised to the degree of a polynomial upper bound on `f(n)`, as shown [here](http://cs-www.bu.edu/faculty/homer/330/class-lect-files/masterhandout.pdf). I'm using the generic form given [here](http://en.wikipedia.org/wiki/Master_theorem#Generic_form) – Asad Saeeduddin Mar 06 '15 at 19:34
  • I don't think it's possible that this is Theta(lg lg lg n). The top level recurrence is T(n) = T(sqrt(n)) + Theta(lg lg n), so T(n) has to be at least Omega(lg lg n). I'm not sure where the math broke down, though. – templatetypedef Mar 06 '15 at 19:36
  • @aneena You do indeed need to just compare both, which is what I'm doing. For the second case, you basically need to test whether `f(n)` takes the form `Ө(n^(log_b(a)) + log^k(n))`. As you can see above, it does, hence the second case applies. – Asad Saeeduddin Mar 06 '15 at 19:36
  • @templatetypedef I'm pretty sure `lg^k(n)` is shorthand for `(lg(n))^k`, not recursively applied log. This is why I wrote `lg^2(lg(n))`, and not `lg^3(n)`. – Asad Saeeduddin Mar 06 '15 at 19:37
  • @templatetypedef `lg(lg(n))` is of course `O(lg(lg(n))^2)`, so you're not wrong when you say the result should be lower bounded by `lg(lg((n)))`. – Asad Saeeduddin Mar 06 '15 at 19:44
  • @Asad as far as I am told we compare f(n) with n^ log_b a... If they are equal then second case applies. – aneena Mar 06 '15 at 19:45
  • Can you explain a bit more maybe I'm missing something and what is k? – aneena Mar 06 '15 at 19:46
  • @aneena There's three cases. The first case applies if `f(n) = O(n^c)`, where `c < log_b(a)`. The second case applies if `f(n) = Ө(n^c * (lg(n))^k)`, where `c = log_b(a)` (the k is important since it shows up in the solution to the recurrence). The third case applies when `n^c = O(f(n))`, or equivalently, `f(n) = Ω(n^c)`, where `c > log_b(a)`. This might be a bit different from the cases you're used to seeing in the master method, because we're defining strict bounds here, rather than being sloppy and just using `O` for everything. – Asad Saeeduddin Mar 06 '15 at 19:58
  • @Asad Ah, I misinterpreted your notation. Thanks for clarifying! – templatetypedef Mar 06 '15 at 20:33
  • how do i get the value of K? – aneena Mar 07 '15 at 01:33
  • @aneena That is the power to which the log term is raised. Eg if I had `T(n) = T(n/2) + Ө(n^2*(lg(n))^3)`, c would be 2 and k would be 3. – Asad Saeeduddin Mar 07 '15 at 02:27
  • I know the but how can I know the power of log or k?what is it supposed to be like in my original question you put k=2 – aneena Mar 07 '15 at 07:52
  • @aneena In your original question `k=1`. The solution to the recurrence in the second case of the master theorem is `T(m)=Ө(m^c * (lg(m))^(k+1))`, which, since `k=1` and `c=0`, is `Ө(lg²(m))` or `Ө((lg(m))^2)`. Please take a look at the Wikipedia article I linked earlier for the master theorem http://en.wikipedia.org/wiki/Master_theorem#Case_2 – Asad Saeeduddin Mar 07 '15 at 19:59
1

First, T(n) = T(n^(1/2)) + theta(lg lg n) can be written as

T(2^(2^k)) = T(2^(2^(k-1))) + theta(k).

Aggregating the above equation for k=1 to d gives T(2^(2^d)) = theta(d^2). Let n=2^(2^d), we obtain T(n) = theta( (lg lg n)^2 ).

Eric
  • 341
  • 1
  • 2
  • 7