How would one go about adding nodes to a binary tree row by row from an array? It's easy enough when elements are added in their proper position based on a key value of some sort, and I have attempted to assign keys to the values in the array in order to do the row by row adding, but I feel like there must be a more elegant way to do this.
To clarify, what I want is to take an array and convert it into a tree like this
_ _ _ 0 _ _ _
_ 1 _ _ _ 2 _
3 _ 4 _ 5 _ 6
where the numbers represent the indices the values had in the initial array