合并排序递归树的高度

发布于 2024-08-29 19:36:02 字数 231 浏览 0 评论 0原文

我正在学习递归树,并试图弄清楚树的高度如何是 n 的 log b,其中 n = 2 并且有 10 个元素作为输入大小。我正在使用合并排序。

据我所知,分割完成的次数就是树的高度,树的层数是高度+1。

但是如果你取(对于合并排序)log2为10,你会得到1,其中如果你画出树,你会得到至少 2 次递归发生。

我哪里出错了? (我希望我在这里说得有道理)

注意:我正在做自学,这不是作业!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云之铃。 2024-09-05 19:36:02

log2(10) = 3.321928094887362...

无论如何,递归调用深度为 O(log(n)),基本上意味着“按 log(n) 的顺序”。 O(log(n)) 算法的实际调用深度可能是 k*log(n)+c,甚至是 k*log(n)+α(n)/log(log(n))+c。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文