Given number of nodes N (ie a preorder seq of length N) in a balanced binary tree,I am trying to find the number b
of possible balanced binary trees that can be formed.
I noticed it is possible that there might be variations in the leaves as well as the higher-level nodes:
A
/ \
B C
/ / \
D E F
/
G
The constraint is generally applied recursively to every subtree. That is, the tree is only balanced if:
1.The left and right subtrees' heights differ by at most one, AND
2.The left subtree is balanced, AND
3.The right subtree is balanced