Ejemplo n.º 1
0
        public void InorderTraversalTest(int[] arrInput, string arrOutput)
        {
            string result = string.Empty;

            InorderTraversal.StartOrder(arrInput, ref result);

            Assert.AreEqual(result.Trim(), arrOutput);
        }
Ejemplo n.º 2
0
        public void TestInorderTraversal()
        {
            TreeNode <int>   root       = new TreeNode <int>(1);
            ITraversal <int> _traversal = new InorderTraversal <int>();

            root.Left       = new TreeNode <int>(2);
            root.Right      = new TreeNode <int>(3);
            root.Left.Right = new TreeNode <int>(5);
            root.Left.Left  = new TreeNode <int>(4);

            var         binarytree     = new BinaryTree <int>(root, _traversal);
            IList <int> expectedOutput = new List <int>(new List <int> {
                4, 2, 5, 1, 3
            });
            var output = binarytree.Traverse();

            CollectionAssert.Equals(expectedOutput, output);
        }