在二进制堆中删除 [英] Deletion in binary heap
问题描述
我只是想学习二进制堆,并怀疑在二进制堆中进行删除操作。
我已经读过,我们可以从二进制堆中删除一个元素,我们需要重新处理它。
但是在以下链接中,它表示不可用: p>
http://en.wikibooks.org/维基/数据结构/权衡
二进制搜索AVL树二进制堆(最小)二项式队列(最小)
查找O(log n)O(log n)不可用
删除元素O(log n O(log n)不可用不可用
我很困惑。
提前感谢所有的澄清。
二进制堆和其他优先级队列结构通常不支持常规的删除元素操作;您需要一个追踪数据的附加数据结构堆中的每个元素的索引,例如哈希表你可以实现一般的删除操作作为
- find-element,O(1)预期的时间与哈希表
- 减少密钥< a>到小于最小值,O(lg n )time
- delete-min并更新哈希表,O(lg em>)组合预期时间。
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屋!