K Balanced Binary Tree Algorithm