Ejemplo n.º 1
0
        public void When_RootHasOneChild_Then_HeightIsOne()
        {
            Chapter10.BinaryTree binaryTree = new Chapter10.BinaryTree(5);
            binaryTree.Insert(2);

            Assert.AreEqual(1, Chapter10._01_GetNodeHeight(binaryTree.Root));
        }
Ejemplo n.º 2
0
        public void When_TreeIsUnbalanced_Then_HeightIsMaxOfLeftAndRight()
        {
            Chapter10.BinaryTree binaryTree = new Chapter10.BinaryTree(5);
            binaryTree.Insert(2);
            binaryTree.Insert(7);
            binaryTree.Insert(8);
            binaryTree.Insert(9);

            Assert.AreEqual(3, Chapter10._01_GetNodeHeight(binaryTree.Root));
        }
Ejemplo n.º 3
0
 public void When_TreeOnlyHasRoot_Then_HeightIsZero()
 {
     Chapter10.BinaryTree binaryTree = new Chapter10.BinaryTree(5);
     Assert.AreEqual(0, Chapter10._01_GetNodeHeight(binaryTree.Root));
 }