Example #1
0
        public void IsBalancedTest6()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(1);

            bool actual = BinaryTreeHelper.IsBalancedBinaryTree(node1);

            Assert.AreEqual(actual, true);

            ClearUpTreeNode(node1);
        }
Example #2
0
        public void IsBalancedTest5()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(1);
            BinaryTreeNode node2 = new BinaryTreeNode(2);
            BinaryTreeNode node3 = new BinaryTreeNode(3);
            BinaryTreeNode node4 = new BinaryTreeNode(4);
            BinaryTreeNode node5 = new BinaryTreeNode(5);

            SetSubTreeNode(node1, null, node2);
            SetSubTreeNode(node2, null, node3);
            SetSubTreeNode(node3, null, node4);
            SetSubTreeNode(node4, null, node5);

            bool actual = BinaryTreeHelper.IsBalancedBinaryTree(node1);

            Assert.AreEqual(actual, false);

            ClearUpTreeNode(node1);
        }
Example #3
0
        public void IsBalancedTest1()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(1);
            BinaryTreeNode node2 = new BinaryTreeNode(2);
            BinaryTreeNode node3 = new BinaryTreeNode(3);
            BinaryTreeNode node4 = new BinaryTreeNode(4);
            BinaryTreeNode node5 = new BinaryTreeNode(5);
            BinaryTreeNode node6 = new BinaryTreeNode(6);
            BinaryTreeNode node7 = new BinaryTreeNode(7);

            SetSubTreeNode(node1, node2, node3);
            SetSubTreeNode(node2, node4, node5);
            SetSubTreeNode(node3, node6, node7);

            bool actual = BinaryTreeHelper.IsBalancedBinaryTree(node1);

            Assert.AreEqual(actual, true);

            ClearUpTreeNode(node1);
        }
Example #4
0
        public void IsBalancedTest7()
        {
            bool actual = BinaryTreeHelper.IsBalancedBinaryTree(null);

            Assert.AreEqual(actual, true);
        }