在二进制堆中删除 [英] Deletion in binary heap

查看:206
本文介绍了在二进制堆中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想学习二进制堆,并怀疑在二进制堆中进行删除操作。
我已经读过,我们可以从二进制堆中删除一个元素,我们需要重新处理它。



但是在以下链接中,它表示不可用: p>

http://en.wikibooks.org/维基/数据结构/权衡

 二进制搜索AVL树二进制堆(最小)二项式队列(最小)

查找O(log n)O(log n)不可用
删除元素O(log n O(log n)不可用不可用

我很困惑。



提前感谢所有的澄清。

解决方案

二进制堆和其他优先级队列结构通常不支持常规的删除元素操作;您需要一个追踪数据的附加数据结构堆中的每个元素的索引,例如哈希表你可以实现一般的删除操作作为




I am just trying to learn binary heap and have a doubt regarding doing delete operation in binary heap. I have read that we can delete an element from binary heap and we need to reheapify it.

But at the following link, it says unavailable:

http://en.wikibooks.org/wiki/Data_Structures/Tradeoffs

                Binary Search  AVL Tree   Binary Heap (min)  Binomial Queue (min)

Find            O(log n)       O(log n)   unavailable         unavailable
Delete element  O(log n        O(log n)   unavailable         unavailable

I am little confused about it.

Thanks in advance for all of the clarifications.

解决方案

Binary heaps and other priority queue structures don't usually support a general "delete element" operation; you need an additional data structure that keeps track of each element's index in the heap, e.g. a hash table. If you have that, you can implement a general delete operation as

  • find-element, O(1) expected time with a hash table
  • decrease key to less than the minimum, O(lg n) time
  • delete-min and update the hash table, O(lg n) combined expected time.

这篇关于在二进制堆中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆