Implement:
bool tree_isBalanced(tree_t tree);
// EFFECTS: returns true if tree is balanced, false otherwise
Given the following functions that you can assume to have been implemented for you:
bool tree_isEmpty(tree_t tree);
// EFFECTS: returns true if tree is empty, false otherwise
tree_t tree_make();
// EFFECTS: creates an empty tree.
tree_t tree_make(int elt, tree_t left, tree_t right);
// EFFECTS: creates a new tree, with elt as it's element, left as
// its left subtree, and right as its right subtree
int tree_elt(tree_t tree);
// REQUIRES: tree is not empty
// EFFECTS: returns the element at the top of tree.
tree_t tree_left(tree_t tree);
// REQUIRES: tree is not empty
// EFFECTS: returns the left subtree of tree
tree_t tree_right(tree_t tree);
// REQUIRES: tree is not empty
// EFFECTS: returns the right subtree of tree
A tree is balanced if it's right subtree and left subtree are the same height for every node in the tree. The height of a tree is defined as the number of nodes that exist in a path from the root of the tree to the deepest node in the tree. A tree with only one node has a height of one and an empty tree has a height of zero. Therefore, empty trees are trivially considered perfectly balanced.
How can I deal with the recursion growing as we move down a tree?