Exemplo n.º 1
0
static __inline void fixTreeHeight(TreeNodeT * root) {
	assert(root != NULL);
	root->height = 1 + maximum(treeHeight(root->l_child), treeHeight(root->r_child));
}
Exemplo n.º 2
0
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;
 }
Exemplo n.º 4
0
 bool IsBalanced_Solution(TreeNode* pRoot) {
     treeHeight(pRoot);
      
     return ok;
 }
Exemplo n.º 5
0
int treeHeight(Node *node) {
	if(node == NULL) return 0;
	return 1+ MAX(treeHeight(node->left), treeHeight(node->right));
}