Content deleted Content added
Root of tree is index 0 |
Bryanlharris (talk | contribs) m grammer correction |
||
Line 1:
[[de:Binärer Heap]][[pl:Kopiec (informatyka)]]
'''Binary heaps''' are a particular kind of [[heap]] such that each node only has two children. Binary heaps are commonly represented by [[array]]s of values. For example, the root of the tree could be item 0 in the array, and the children of item ''n'' are the items at 2''n''+1 and 2''n''+2; so item 0's children are items 1 and 2, 1's children are items 3 and 4, etc. This allows you to regard any 1-based array as a possibly-screwed-up heap.
The diagram on the left is somewhat deceptive in that heaps are conventionally in decreasing order rather than increasing order because of their use as [[priority queue]]s. The diagram on the right is a more traditional heap.
|