So I was calculating average case complexity of the following function using Master's theorem:
T(n) = 2T (n/2)+ n/ log n
According to http://people.csail.mit.edu/thies/6.046-web/master.pdf Question 7,
It says
Does not apply (non-polynomial difference between f(n) and n log b a )
This answer also supports pdf, by saying NO.
However, in this video instructor has solved same question at 12:26, he came out with answer
Θ(nloglogn)
Can anyone explan which one is wrong and why?
They are both right. The Master Theorem in the PDF does not apply, but the instructor in the video is using an extended form of the master theorem that covers your case.
I wasn't able to find any really good references to the version in the video, and it's not the version I learned, but there is a proof of it online here: http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/extended_master_theorem.pdf
As Matt Timmermans correctly notes, the statement doesn't follow from the master theorem, but it does follow from an extended version of it.
It's quite simple to solve this problem directly using the tree method.
Starting with T(n) = 2T (n/2)+ n / log n:
Level 0 has 1 node with value n / log(n).
Level 1 has 2 nodes, each with value (n / 2) / log(n / 2).
...
Level i has 2i nodes, each with value (n / 2i) / log(n / 2i)
Simplifying, level i contributes n / (log(n) - i).
Note that, altogether, there are ~log(n) - 1 levels to reach a constant.
Consequently, the sum of all levels is ∑i = 0~log(n) - 1[n / (log(n) - i)] ~ n ∑i = 0k[1 / k],
for k = log(n).
Note that the sigma is the kth harmonic series, which is Θ(log(k)). Setting k = log(n) gives altogether n Θ(log(log(n))) = Θ(n log(log(n))).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With