Content deleted Content added
m →Insert: Copyedit |
→Derivation of index equations: Copyedit (1) |
||
Line 262:
In an array-based heap, the children and parent of a node can be located via simple arithmetic on the node's index. This section derives the relevant equations for heaps with their root at index 0, with additional notes on heaps with their root at index 1.
To avoid confusion, we
=== Child nodes ===
Line 289:
\end{alignat}
</math>
Noting that the left child of any node is always 1 place before its right child, we get <math>\text{left} = 2i + 1</math>.
Line 298 ⟶ 296:
=== Parent node ===
Every non-root node is either the left or right child of its parent, so
Hence,
|