[英]Complexity of the recurrence T(n)=T(n−2)+1/lgn?
This is a problem from the CLRS book.这是 CLRS 书中的一个问题。 The Introduction to Algorithms Study Group website gave the following answer to it:算法导论研究组网站对此给出了如下回答:
( http://clrs.skanev.com/04/problems/03.html ) ( http://clrs.skanev.com/04/problems/03.html )
Is this answer right?这个答案对吗? I don't understand the last two lines.最后两行没看懂
No, it's not.不,这不对。 Also there's a typo, instead of infinity there should be n.还有一个错字,应该是n而不是无穷大。 For strict mathematical proof you should ask on another stackExchange site (mathematical one).对于严格的数学证明,您应该在另一个 stackExchange 站点(数学站点)上询问。 But for your intuition I can show the following.但为了你的直觉,我可以展示以下内容。
Let's imagine that n = 2^2^k
then sum of 1/lg(i)
equals假设n = 2^2^k
那么sum of 1/lg(i)
等于
1/lg2 + 1/lg3 + 1/lg4 + 1/lg5 + 1/lg6 + 1/lg7 + 1/lg8 + 1/lg9 +
1/lg10 + 1/lg11 + 1/lg12 + 1/lg13 + 1/lg14 + 1/lg15 + ... + 1/lg n-1
and this is approximately这大约是
1/lg2 + 1/lg2 + 1/lg4 + 1/lg4 + 1/lg4 + 1/lg4 + 1/lg8 + 1/lg8 +
1/lg8 + 1/lg8 + 1/lg8 + 1/lg8 + 1/lg8 + 1/lg8 + ... + 1/lg n-1
equals等于
1/1 + 1/1 + 1/2 + 1/2 + 1/2 + 1/2 + 1/3 + 1/3 +
1/3 + 1/3 + 1/3 + 1/3 + 1/3 + 1/3 + ... + 1/ (2^k - 1) (as lg n = 2^k)
After combining we have合并后我们有
sum(1/i * 2^i) from 1 to 2^k-1
where the last member is n/2 / 2^k-1
which is something about 2^(2^kk-1)
and this is far not theta of lg lg n = k
.其中最后一个成员是n/2 / 2^k-1
,大约是2^(2^kk-1)
,这远不是lg lg n = k
θ。 And of course the whole sum is even bigger.当然,整个金额更大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.