Brain Dump

Arrays as Trees

Tags
comp-sci

You can represent any contiguous array of elements as a binary-tree where:

\begin{align} \text{Parent}(i) &= \lfloor \frac{i}{2} \rfloor \
\text{Left}(i) &= 2i \
\text{Right}(i) &= 2i + 1 \end{align}

Figure 1: Visualisation of the relation between an array and a tree.

Figure 1: Visualisation of the relation between an array and a tree.

Links to this note