Error in the ocde

@tharun hey only recursion cant check whether tree is balanced or not you have to also check diff of height and check whether left subtree is balanced or not similiarly for right,check this pseudo code:
bool isBalanced(node* root)

{

int lh; /* for height of left subtree */

int rh; /* for height of right subtree */

/* If tree is empty then return true */

if (root == NULL)

return 1;

/* Get the height of left and right sub trees */

lh = height(root->left);

rh = height(root->right);

if ( abs (lh - rh) <= 1 && isBalanced(root->left) && isBalanced(root->right))

return 1;

/* If we reach here then

tree is not height-balanced */

return 0;

}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.