For example the array [1,2,3,4,5] must be transformed to the following binary tree
We can use the divide and conquer approach to solve this problem. To create a balanced tree, the number of nodes on the left sub-tree should be almost equal to that of right sub-tree.
How do we do it?
Here is the C++ code.