Can you explain me the condition in del function of avl?


Please explain the condition in delete function in which we are checking on step 3: if(bal>1 && getBalance(root->left)>=0)
how it is ofr left of left. I mean I got first condition of bal > 1 but not second getBalance(root->left)>=0 . Please help me.

getBalance(root->left) >= 0 is to check if tree is unbalanced due to left subtree of root->left. So, if the resulting value is greater than equal to 0, that means height of root->left->left subtree is greater than equal to that of root->left->right subtree and since bal > 1 that means tree is unbalanced due to left subtree. Hence for value greater than equal 0 it will result in a left left case.

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.