Skip to content

Instantly share code, notes, and snippets.

@sarahzhao25
Created January 27, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarahzhao25/5da550a5c0358ac083b25c71c10e38d9 to your computer and use it in GitHub Desktop.
Save sarahzhao25/5da550a5c0358ac083b25c71c10e38d9 to your computer and use it in GitHub Desktop.
//ROOT Tree (rotated to RIGHT):
{
this.value = 15;
this.left = null;
this.right = null;
this.parent = {node: BST(10), side: 'right'};
}
//root.height() => 0;
//root.balanceFactor() => 0;
//PIVOT Tree (rotated to ROOT):
{
this.value = 10;
this.left = BST(7);
this.right = BST(15);
this.parent = {node: BST(20), side: 'left'};
}
//pivot.height() => 1;
//pivot.balanceFactor() => 0;
//PARENT Tree (of root):
{
this.value = 20;
this.left = BST(10);
this.right = BST(25);
this.parent = {node: null, side: ''}
}
//parent.height() => 2;
//parent.balanceFactor() => 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment