getting only test case 2 wrong
Is_balanced test case wrong
Faizan, I think the logic you are using in your function is wrong, work as per this logic, since you havent taken the difference of the left and right subtrees in your code…
bool isBalanced(node *root)
{
if(root==NULL)
{
return true;
}
int lh,rh;
lh=height(root->left);
rh=height(root->right);
if(abs(lh-rh)<=1 && isBalanced(root->left) && isBalanced(root->right))
{
return true;
}
return false;
}