I am working on a small algorithm that builds a binary tree in level order. I am given an array and I must use the values in it to build a binary tree in level order. Example: arr inarr[5]={1,2,3,4,5};
given an array like this I need to fill in a binary tree to look like this:
1
/ \
2 3
/ \ / \
4 5 * *
(* are NULL) the nodes are basic binary nodes with a left and right pointer and a space for an int which holds a value from the array.
I understand the concept of traversing the tree based on it's height and you move through it one level at a time, but I am unsure of the correct logic that builds it in this way correctly.
arr inarr[5]={3,1,2,4,5};
? – chux - Reinstate Monica