Next: Arithmetic of Tree Traversal
Up: Binary Heaps and Priority
Previous: Complete Binary Trees
  Index
Array Representation
A complete binary tree has a simple array representation. Suppose we
number the nodes from left to right, beginning at the top and ending
at the bottom. Then we can store the various data items in the
corresponding elements of an array. For example
can be represented by the array
This in fact corresponds to the level order enumeration of the tree.
Note that we only use an initial segment of the array. Provided the
array is long enough, and we know the number of tree nodes, it doesn't
matter how many unused components there are at the end.
Subsections
Peter Williams
2005-06-07