大家好,我刚刚有一个关于这张图的问题。 我如何知道哪个节点是根节点以及我将如何堆积这样的东西?
谢谢。
Edit: Sorry, when I said heapify I meant make a max heap. Normally with a regular heap, I would go from left to right, starting at the first node that isn't a leaf node and sift downwards. I don't see how I can do that here though.
最佳答案
这是一个二项式堆,它没有一个根而是一组根(因为二项式堆是一组二项式树)。
“制作最大堆”是什么意思? 最大堆和二项式堆之间的距离与 java 和 javascript 之间的距离一样近。
如果你提取最小n次,你可以得到一个排序数组,它是一个最大堆。复杂度为 O(n*log(n))。
关于algorithm - 如果你有一个大小为 14 的二项式堆,你怎么知道哪个节点是根节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13784780/