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}
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}