static __inline void fixTreeHeight(TreeNodeT * root) { assert(root != NULL); root->height = 1 + maximum(treeHeight(root->l_child), treeHeight(root->r_child)); }
static __inline int nodeBalanceFlag(const TreeNodeT* node) { assert(node != NULL); return treeHeight(node->l_child) - treeHeight(node->r_child); }
bool isBalanced(TreeNode *root) { if (treeHeight(root) == -1) { return false; } return true; }
bool IsBalanced_Solution(TreeNode* pRoot) { treeHeight(pRoot); return ok; }
int treeHeight(Node *node) { if(node == NULL) return 0; return 1+ MAX(treeHeight(node->left), treeHeight(node->right)); }