Hi Muhammad,

The node that contains the value 10 should have a height of -1, because it only has one node to the left of it and no node to the right. From this we conclude that the height of the node that contains the value 10 is right-left = 0–1 = -1 .

The height of node 22 should be 0, because it has no children so it is therefor already balanced, or we can say its right -left = 0–0 = 0.

Thanks for reading my article!
randerson112358

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store