Difference between solving T(n) = 2T(n/2) + n/log n and T(n) = 4T(n/2) + n/log n using Master Method

倖福魔咒の 提交于 2019-12-24 02:23:24

问题


I recently stumbled upon a resource where the 2T(n/2) + n/log n type of recurrences were declared unsolvable by MM.

I accepted it as a lemma, until today, when another resource proved to be a contradiction (in some sense).

As per the resource (link below): Q7 and Q18 in it are the rec. 1 and 2 respectively in the question whereby, the answer to Q7 says it can't be solved by giving the reason 'Polynomial difference b/w f(n) and n^(log a base b)'. On the contrary, answer 18 solves the second recurrence (in the question here) using case 1.

http://www.csd.uwo.ca/~moreno/CS433-CS9624/Resources/master.pdf

Can somebody please clear the confusion?


回答1:


If you try to apply the master theorem to

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

You consider a = 2, b = 2 which means logb(a) = 1

  1. Can you apply case 1?0 < c < logb(a) = 1. Is n/logn = O(n^c). No, because n/logn grow infinitely faster than n^c
  2. Can you apply case 2? No. c = 1 You need to find some k > 0 such that n/log n = Theta(n log^k n )
  3. Can you apply case 3 ? c > 1, is n/logn = Big Omega(n^c) ? No because it is not even Big Omega(n)

If you try to apply the master theorem to

T(n) = 4T(n/2) + n/log n

You consider a = 4, b = 2 which means logb(a) = 2

  1. Can you apply case 1? c < logb(a) = 2. is n/logn = O(n^0) or n/logn = O(n^1). Yes indeed n/logn = O(n). Thus we have

    T(n) = Theta(n^2)
    

note: Explanation about 0 < c <1, case 1

The case 1 is more about analytics.

f(x) = x/log(x) , g(x) = x^c , 0< c < 1
f(x) is O(g(x)) if f(x) < M g(x) after some x0, for some M finite, so 
f(x) is O(g(x)) if f(x)/g(x) < M cause we know they are positive

This isnt true here We pose y = log x

f2(y) = e^y/y , g2(y) = e^cy , 0< c < 1
f2(y)/g2(y) = (e^y/y) / (e^cy) = e^(1-c)y / y  , 0< c < 1

lim inf f2(y)/g2(y) = inf
lim inf f(x)/g(x) = inf



回答2:


This is because in Q18 we have a = 4 and b = 2, thus we get that n^{log(b,a)} = n^2 which has an exponent strictly bigger than the exponent of the polynomial part of n/log(n).



来源:https://stackoverflow.com/questions/28093121/difference-between-solving-tn-2tn-2-n-log-n-and-tn-4tn-2-n-log-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!