当使用二项堆?二项堆

2023-09-11 05:41:12 作者:伴着你等明天

二项堆有比较特别的设计。就个人而言,我不认为这样的设计是直观的。

Binomial Heap has quite special design. Personally I don't think this design is intuitive.

虽然职位如What是二进制堆和二项堆?了解更多的比较和专业的谈判之间的区别,我仍然不知道什么时候我应该使用它。

Although posts such as What is the difference between binary heaps and binomial heaps? talks about diff and its speciality, I am still wondering when I should use it.

在 http://en.wikipedia.org/wiki/Binomial_heap ,它说

,以便为k的二叉树可   平凡通过附加一个从订单K-1的两棵树构造   它们作为另一个根的最左子。此功能   中央向一个二项式堆的合并操作,这是它的主要   优于其它传统的堆。

Because of its unique structure, a binomial tree of order k can be constructed from two trees of order k−1 trivially by attaching one of them as the leftmost child of root of the other one. This feature is central to the merge operation of a binomial heap, which is its major advantage over other conventional heaps.

余presumes该二项式堆的优点是它的合并。然而,左倾堆也有O(logN)的合并,更简单,为什么我们还在用二项式堆?什么时候应该使用二项堆?

I presumes that an advantage of Binomial Heap is its merge. However, Leftist heap also has O(logN) merge and much simpler, why we still use Binomial Heap? When should I use Binomial Heap?

修改

一个我想请问这里的实际问题是什么是二项堆正好优势

One of the actual question I wanna ask here is What's exactly the advantage of Binomial Heap?

推荐答案

这篇文章的左树说:

当插入新节点插入一棵树,一个新节点树创建并合并到现有的树。要删除一个最小的项目,我们删除根和左,右子树,然后合并。这两种操作需要O(log n)的时间。对于插入,这比支持插入分期常量时间二项式堆慢,O(1)和O(log n)的最坏情况。

When inserting a new node into a tree, a new one-node tree is created and merged into the existing tree. To delete a minimum item, we remove the root and the left and right sub-trees are then merged. Both these operations take O(log n) time. For insertions, this is slower than binomial heaps which support insertion in amortized constant time, O(1) and O(log n) worst-case.

因此​​,它似乎二项式堆的优点在于,插入更快。

So it appears that the advantage of Binomial heap is that insertions are faster.

至少,这就是asympotitic分析告诉我们。运行时间现实世​​界完全是另一回事,正如基因在他的回答说,取决于常数因子。你能确定这是你的应用程序更好的唯一方法是测试他们。

At least, that's what asympotitic analysis tells us. Real world running time is something else entirely and, as Gene said in his answer, depends on constant factors. The only way you can determine which is better for your application is to test them.

相关推荐