Heaps
To represent a complete binary tree as an array:
The root node is A[1]
Node i is A[i]
The parent of node i is A[i/2] (note: integer divide)
The left child of node i is A[2i]
The right child of node i is A[2i + 1]
16
14
10
8
7
9
3
2
4
1
A =
=
Previous slide
Next slide
Back to first slide
View graphic version