Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solve the recurrence: T(n)=2T(n/2)+n/logn

I can find the sum of each row (n/log n-i) and also I can draw its recursive tree but I can't calculate sum of its rows.

T(n)=2T(n/2)+n/logn

T(1) = 1

like image 357
Saeedeh Avatar asked Aug 25 '12 06:08

Saeedeh


2 Answers

Suppose n = 2^k;

We know for harmonic series (euler formula):

Sum[i = 1 to n](1/i) ~= log(n) [n -> infinity]

t(n) = 2t(n/2) + n/log(n)
     = 2(2t(n/4) + n/2/log(n/2)) + n/log(n)
     = 4t(n/4) + n/log(n/2) + n/log(n)
     = 4(2t(n/8) + n/4/log(n/4)) + n/log(n/2) + n/log(n)
     = 8t(n/8) + n/log(n/4) + n/log(n/2) + n/log(n)
     = 16t(n/16) + n/log(n/8) + n/log(n/4) + n/log(n/2) + n/log(n)
     = n * t(1) + n/log(2) + n/log(4) + ... + n/log(n/2) + n/log(n)
     = n(1 + Sum[i = 1 to log(n)](1/log(2^i)))
     = n(1 + Sum[i = 1 to log(n)](1/i))
     ~= n(1 + log(log(n)))
     = n + n*log(log(n)))
     ~= n*log(log(n)) [n -> infinity]
like image 70
Danil Speransky Avatar answered Sep 18 '22 23:09

Danil Speransky


When you start unrolling the recursion, you will get:

enter image description here

Your base case is T(1) = 1, so this means that n = 2^k. Substituting you will get:

enter image description here

The second sum behaves the same as harmonic series and therefore can be approximated as log(k). Now that k = log(n) the resulting answer is:

enter image description here

like image 30
Salvador Dali Avatar answered Sep 19 '22 23:09

Salvador Dali