Asymptotic analysis

孤者浪人 提交于 2019-11-29 11:03:27

So your question can be actually reduced to "What is the tight bound for the harmonic series 1/1 + 1/2 + 1/3 + ... + 1/N?" For which the answer is log N (you can consider it as continuous sum instead of discrete, and notice that the integral of 1/N is log N)

Your harmonic series is the formula of the whole algorithm (as you have correctly concluded)

So, your sum:

N + N/2 + N/3 + ... + N/N = N * (1 + 1/2 + 1/3 + ... + 1/N) = Theta(N * log N)

So the tight bound for the algorithm is N*log N

See the [rigorous] mathematical proof here (see the "Integral Test" and "Rate of Divergence" part)

Well, you can methodically use Sigma notation:

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