Exemplo n.º 1
0
 int countNodes(TreeNode* root) {
     if (!root)
         return 0;
     
     int left = getLeftHeight(root);
     int right = getRightHeight(root);
     
     if (left == right) {
         return (2 << (left - 1)) - 1;
     }
     else {
         return countNodes(root->left) + countNodes(root->right) + 1;
     }
     
     return 0;
 }
Exemplo n.º 2
0
static int case4(TLDNode *x)
{
    return (getLeftHeight(x) < getRightHeight(x))
            && ( getRightRightHeight(x) > getRightLeftHeight(x));
}