예제 #1
0
 private bool IsRightHeavy(AVLNode node)
 => BalanceFactor(node) < -1;
예제 #2
0
 private bool IsLeftHeavy(AVLNode node)
 => BalanceFactor(node) > 1;
예제 #3
0
 private int BalanceFactor(AVLNode node)
 => node == null ? 0 : GetHeight(node.LeftChild) - GetHeight(node.RightChild);
예제 #4
0
 private bool IsLeaf(AVLNode node)
 => node.LeftChild == null && node.RightChild == null;
예제 #5
0
 private void SetHeight(AVLNode node)
 {
     node.Height = 1 + Math.Max(GetHeight(node.LeftChild), GetHeight(node.RightChild));
 }
예제 #6
0
 public void Insert(int value)
 {
     Root = Insert(Root, value);
 }