Content deleted Content added
Vince Vatter (talk | contribs) m wikified Sack |
Added missing space complexity - it was not only missing but produced a poorly formatted page. |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1:
{{Short description|Variant of heap data structure}}
{{Infobox data structure
| name = Binary (min) heap
| type = binary tree/heap
| invented_by = [[J. W. J. Williams]]
| invented_year = 1964
<!-- NOTE:
For the purposes of "Big O" notation, all bases are equivalent, because changing the base of a log only introduces a constant factor.
Line 10:
DO: O(log n)
DON'T: O(lg n), O(log2 n), O(log_2 n), O(ln n), O(log10 n), etc.
-->| insert_worst = O(log ''n'')▼
| insert_avg = O(1)▼
▲|insert_worst=O(log ''n'')
▲|insert_avg=O(1)
|
|
|
| find_min_avg = O(1)
▲|decrease_key_worst=O(log ''n'')
|
| merge_avg = O(''n'')
|
|
| space_worst = O(n)
}}
[[File:Max-Heap.svg|thumb|right|Example of a complete binary max-heap]]
[[File:Min-heap.png|thumb|right|Example of a complete binary min heap]]
Line 32 ⟶ 34:
*Inserting an element;
*Removing the smallest or largest element from (respectively) a min-heap or max-heap.
Binary heaps are also commonly employed in the [[heapsort]] [[sorting algorithm]], which is an in-place algorithm
==Heap operations==
|