Skip to content

Instantly share code, notes, and snippets.

@sarahzhao25
Created January 27, 2018 14:53
Show Gist options
  • Save sarahzhao25/7822547cea10d741709f899d1754a6b3 to your computer and use it in GitHub Desktop.
Save sarahzhao25/7822547cea10d741709f899d1754a6b3 to your computer and use it in GitHub Desktop.
//ROOT Tree:
{
this.value = 15;
this.left = BST(10);
this.right = null;
this.parent = {node: BST(20), side: 'left'};
}
//root.height() => 2;
//root.balanceFactor() => 2;
//PIVOT Tree (left of root):
{
this.value = 10;
this.left = BST(7);
this.right = null;
this.parent = {node: BST(15), side: 'left'};
}
//pivot.height() => 1;
//pivot.balanceFactor() => 1;
//PARENT Tree (of root):
{
this.value = 20;
this.left = BST(15);
this.right = BST(25);
this.parent = {node: null, side: ''}
}
//parent.height() => 3;
//parent.balanceFactor() => 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment