This script automatically displays an array in Binary Tree format, whether or not it is a complete binary tree. For this demo the test array contains the first 30 natural numbers.

It can be used in genealogy to display an individual's ancestral tree, which is binary, unlike the descendants tree which is non-binary.

Note: if we commence numbering the nodes of a binary tree at 1, then for any child of node number Nc , the node number of its parent is given by the following formula:

Np = (Nc - Nc%2)/2

Javascripts Page | Home