Search code examples
algorithmdata-structuresrecurrencemaster-theorem

Solve Recurrence Relation by Master theorem?


Can someone please clarify this solution a little more?

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

Solution:

Let k = log n,

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

Substituting into this the equation S(k) = T(2^k)

we get that

S(k)=2S(k/2) + k

Now, this recurrence equation allows us to use master theorem, which specifies that

S(k) is O(k log k). Substituting back for T(n) implies T(n) is O(log n log log n)


Solution

  • How many times can you keep dividing n by 2? Log_2(n) times. Because Log_2(n) is to what power you need to raise 2, to get n.

    Also loglog(n) is how many times you can take the square root of n, so maybe that substitution isn't that necessary, if you know this.