Next: Array Representation
Up: Binary Heaps and Priority
Previous: Binary Heaps and Priority
  Index
Complete Binary Trees
Trees satisfying property
(H)
are particularly useful if they are well balanced, in the sense of
having short path lengths from root to leaves. They don't have to be
quite as well balanced as the tree above. All we require is that the
path lengths are as short as possible. For example, we could have
or
or even
But we don't want are trees like
in which there are paths from some leaf to the root whose lengths
differ by more than 1. We want trees in which every level is fully
occupied except, possibly, for the bottom level.
It is also very convenient, as you will see, if the bottom level is
filled from left to right. (It could alternatively be filled from
right to left, but we need to agree on one or the other.) Binary
trees of this type are called complete.
They are defined as being completely filled, except possibly for the
bottom level, which is filled from left to right. A complete
binary tree which also satisfies the ordering property
(H) is called a binary heap.
Next: Array Representation
Up: Binary Heaps and Priority
Previous: Binary Heaps and Priority
  Index
Peter Williams
2005-06-07