有人可以帮帮我吗?
我知道第一步是:
n = 2^i
T(2^i)=5T(2^i/2) + lg(2^i)
T(2^i)=5T(2^i-1) + lg(2^i)
define t(i) = T(2^i)
t(i)-5t(i-1)-lg(2^i)
我对LOG不太好,有人可以指导我吗?
答案 0 :(得分:-1)
T(n) = 2*T(n/2) + lg(n)
= (2^2*T(n/2^2) + 2*lg(n/2)) + lg(n)
= 2^3*T(n/2^3) + 2^2*lg(n/2^2) + 2*lg(n/2) + lg(n)
... ... ...
= 2^i*T(n/2^i) + 2^(i-1)*lg(n/2^(i-1)) + 2^(i-2)*lg(n/2^(i-2)) + .. + 2*lg(n/2^1) + lg(n)
= n*T(1) + 2^(i-1)*lg(2) + 2^(i-2)*lg(2^2) + .. + 2*lg(2^(i-1)) + lg(2^i), where n = 2^i
= n*1 + (2^(i-1) + 2*2^(i-2) + 3*2^(i-3) + ... + (i-1)*2 + i*1)
= n + (2^(i+1) - 2 - i) .... (1)
= n + 2*n - 2 - lg(n)
= 3*n - lg(n) - 2
我们可以在这里显示(1)如下:
S = 2^(i-1) + 2*2^(i-2) + 3*2^(i-3) + ... + (i-1)*2 + i*1 (3)
2*S = 2^(i) + 2*2^(i-1) + 3*2^(i-2) + 4*2^(i-3) + ... + (i)*2 (4)
(4) - (3) => S = 2^(i) + (2^(i-1) + 2^(i-2) + 2^(i-3) + ... + 2) - i
= 2^(i) + 2*(2^(i-1) - 1)/(2-1) - i
= 2^i + 2^i - 2 - i
= 2^(i+1) - 2 - i