Last active
January 9, 2018 05:40
-
-
Save sarahzhao25/98821a090fa9726f6083eaece757dd18 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
function rotate(root) { | |
if (root.balanceFactor() > 1) { | |
if (root.left.balanceFactor() === -1) leftRotate(root.left); | |
rightRotate(root); | |
} | |
else if (root.balanceFactor() < -1) { | |
if (root.right.balanceFactor() === 1) rightRotate(root.right); | |
leftRotate(root); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment