HOW THE root value is changing,ie,how are we changing the pointer from one node to the other without returning root in our code?

HOW THE root value is changing,ie,how are we changing the pointer from one node to the other without returning root in our code?

@garganshul151 we are passing left child and right child, recursively.

left=isHeightBalanced(root->left);                // at this point the root is passing its left child and calling function
right= isHeightBalanced(root->right);      // at this point the root is passing its right child and calling 

We do not need to return the head/root of left and write child as we are simply traversing the tree without modifying it. And whatever information needs to be passed upwards is passed using the ‘Hpair’ object.
If this resolves your doubt mark it as resolved.

is this top to bottom approach or vice versa?

@garganshul151 top to bottom, we are going from root to leaf.
if this resolves your doubt mark it as resolved

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.