We say that a binary tree T is perfectly balanced if, for each node n in T , the number of keys in the left and right subtrees of n differ at most by 1.
Write an algorithm called Is-Perfectly-Balanced that, given a binary tree T returns true if T is perfectly balanced, and false otherwise. Also, analyze the complexity of Is-Perfectly-Balanced.