merge sort recursion tree height

我的梦境 提交于 2019-12-13 20:14:44

问题


I am learning about recursion tree's and trying to figure out how the height of the tree is log b of n where n = 2 and one has 10 elements as input size. I am working with Merge sort.

The number of times the split is done is the height of the tree as far as I understood, and the number of levels in the tree is height + 1.

But if you take (for merge sort) log2 of 10 you get 1, where if you draw the tree you get at least 2 times that the recursion occurs.

Where have I gone wrong? (I hope I am making sense here)

NOTE: I am doing a self study, this is not homework!


回答1:


log2(10) = 3.321928094887362...

In any case, the recursive call depth is O(log(n)), which basically means "on the order of log(n)". The actual call depth for an O(log(n)) algorithm might be k*log(n)+c, or even k*log(n)+α(n)/log(log(n))+c.



来源:https://stackoverflow.com/questions/2670374/merge-sort-recursion-tree-height

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