public void BalanceFactorForLeftHeavyTree() { // Arrange var leftOfLeft = new AVLTreeNode <int>(); var left = new AVLTreeNode <int>(); left.Left = leftOfLeft; var root = new AVLTreeNode <int>(); root.Left = left; root.UpdateHeights(); // Act & Assert Assert.Equal(2, root.BalanceFactor); Assert.True(root.TreeIsLeftHeavy); Assert.False(root.TreeIsRightHeavy); Assert.True(root.LeftChildIsLeftHeavy); Assert.False(root.LeftChildIsRightHeavy); Assert.False(root.RightChildIsRightHeavy); Assert.False(root.RightChildIsLeftHeavy); }
public void FindBiggestTest() { // Arrange var parent = new AVLTreeNode <int>(); var right = new AVLTreeNode <int>(); var left = new AVLTreeNode <int>(); var leftOfLeft = new AVLTreeNode <int>(); left.Left = leftOfLeft; left.Parent = parent; right.Parent = parent; parent.Right = right; parent.Left = left; // To properly use 'height' info parent.UpdateHeights(); // Act var actual = parent.GetBiggestHeightOfChilds(parent); // Assert Assert.Equal(2, actual); }