Content deleted Content added
Iron Wallaby (talk | contribs) m Removed stupid comment. |
→Heap implementation: Brevity, reword |
||
Line 74:
== Heap implementation ==
It is perfectly possible to use a traditional binary tree data structure to implement a binary heap. There is an issue with finding the adjacent element on the last level on the binary heap when adding an element which can be resolved algorithmically or by adding extra data to the nodes, called "threading" the tree
[[Image:Binary_tree_in_array.png|right|A small complete binary tree stored in an array]]
The upheap/downheap operations can be stated then in terms of an array as follows: suppose that the heap property holds for the indices ''b'', ''b''+1, ..., ''e''. The sift-down function extends the heap property to ''b''-1, ''b'', ''b''+1, ..., ''e''.
|