2.2 Node serialization

Nodes in a heap are identified by their serial numbers. Let us assume that we have a heap in which nodes can have up to k children. The serial number of the root is defined as 1. Let us number children of a node as 0,1,k 1. Then child i of a node with a serial number of n is defined as k n + i.

Given that a node has a serial number of n, then the serial number of its parent is n∕k(the floor of n divided by k).

Combined with the “fill children from left to right” requirement in the previous section, this means node k n + i must be filled before node k n + (i + 1) for some i [0n 2].

Let us assume the leaf with the least serial number is i If there are exactly m leaves in the heap, then one can prove that all the nodes have serial numbers j [ii + m 1].