Exemplo n.º 1
0
 public void Insert(int value)
 {
     root = Insert(root, value);
 }
Exemplo n.º 2
0
 private int Height(AVLNode node)
 {
     return(node?.height ?? -1);
 }
Exemplo n.º 3
0
 private int BalanceFactor(AVLNode node)
 {
     return(node == null ? 0 : Height(node.leftChild) - Height(node.rightChild));
 }
Exemplo n.º 4
0
 private bool IsRightHeavy(AVLNode node)
 {
     return(BalanceFactor(node) < -1);
 }
Exemplo n.º 5
0
 private bool IsLeftHeavy(AVLNode node)
 {
     return(BalanceFactor(node) > 1);
 }
Exemplo n.º 6
0
 private void SetHeight(AVLNode node)
 {
     node.height = Math.Max(Height(node.leftChild), Height(node.rightChild)) + 1;
 }