Created
February 10, 2018 17:22
-
-
Save tarlanahad/b21e5afef7c302590816c1c5301dd733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CheckBalance(Node newNode) { | |
if (Math.abs(height(newNode.Left) - height(newNode.Right)) > 1) {//if difference between children's height gre. than 1 | |
ReBalance(newNode);//rebalance | |
} | |
if (newNode.Parent == null) return;//if we are on in the root | |
CheckBalance(newNode.Parent);//otherwise, check top levels | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment