Skip to content

Instantly share code, notes, and snippets.

@tarlanahad
Created February 10, 2018 17:22
Show Gist options
  • Save tarlanahad/b21e5afef7c302590816c1c5301dd733 to your computer and use it in GitHub Desktop.
Save tarlanahad/b21e5afef7c302590816c1c5301dd733 to your computer and use it in GitHub Desktop.
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