Content deleted Content added
Kill incorrect definition, merge lead section with intro |
added "shape property" |
||
Line 1:
[[Category:Trees (structure)]]
'''Binary heaps''' are a particularly simple kind of [[heap]] [[data structure]] created using a [[binary tree]]. It can be seen as a binary tree with
*The ''shape property'': that the <math>{n}</math>th node of the heap is a child of the <math>\left \lfloor \frac{n}{2} \right \rfloor</math>th node.
*The ''heap property'': that each node is greater than or equal to each of its children.
"Greater than" means according to whatever comparison function is chosen to sort the heap, not necessarily "greater than" in the mathematical sense (since the quantities are not even always numerical). Heaps where the comparison function is mathematical "greater than" are called max-heaps; those where the comparison function is mathematical "less than" are called "min-heaps". Conventionally, max-heaps are used, since they are readily applicable for use in [[priority queue]]s.
1 11
Line 10 ⟶ 16:
8 9 10 11 1 2 3 4
Note that the ordering of siblings in a heap is not specified by the
== Heap operations ==
|