Solving a recurrence T(n) = 2T(n/2) + sqrt(n) [closed]

不想你离开。 提交于 2019-12-04 12:16:41

You're half way there. The expression can be simplified to this:

If you want just a big-O solution, then Master Theorem is just fine.

If you want a exact equation for this, a recursion tree is good. like this:

The right hand-side is cost for every level, it's easy to find a general form for the cost, which is sqrt((2^h) * n). Then, sum up the cost you could get T(n).

  1. According to Master Theorem, it's case 1, so O(n).
  2. According to Recursion Tree, the exact form should be sqrt(n)*(sqrt(2n)-1)*(sqrt(2)+1), which corresponds with the big-O notation.

EDIT:

The recursion tree is just a visualized form of the so called backward substitution. If you sum up the right hand side, i.e. the cost, you could get the generalized form of T(n). All these methods could found in introduction to algorithm

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