Skip to content

Instantly share code, notes, and snippets.

@sarahzhao25
Last active January 6, 2018 21:52
Show Gist options
  • Select an option

  • Save sarahzhao25/1baa9f5bbb80df6dfdf0b5f1ca8b3093 to your computer and use it in GitHub Desktop.

Select an option

Save sarahzhao25/1baa9f5bbb80df6dfdf0b5f1ca8b3093 to your computer and use it in GitHub Desktop.
checkAndRotateRoots(root) {
if (root) {
let x = root.balanceFactor();
if (x > 1 || x < -1) rotate(root);
checkAndRotateRoots(root.parent.node);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment