Ejemplo n.º 1
0
        public void ShouldGenerateInOrderBinaryTreeSucessfully()
        {
            int[] keys = new int[] { 1, 2, 3, 4, 5, 6, 7 };

            Node result = BinaryTreeUtil.CreateInOrderBinaryTree(keys);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.NodeValue == 4);
            Assert.IsTrue(result.Left.NodeValue == 2);
            Assert.IsTrue(result.Right.NodeValue == 6);
        }
Ejemplo n.º 2
0
        private static Node CreateValidBinaryTree()
        {
            /*
             *           6
             *          / \
             *        3     8
             *       / \   / \
             *      1   4 7   9
             */
            int[] keys = new int[] { 1, 3, 4, 6, 7, 8, 9, 10 };

            return(BinaryTreeUtil.CreateInOrderBinaryTree(keys));
        }