Esempio n. 1
0
        public void Test_PostOrderTraversal_Empty_Tree()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //Then
            Assert.Empty(tree.PostOrderTraversal());
        }
Esempio n. 2
0
        public void Test_PostOrderTraversal_Tree_Has_1_Node()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            //Then
            Assert.Equal(new[] { 4 }, tree.PostOrderTraversal());
        }
Esempio n. 3
0
        public void Test_PostOrderTraversal_Root_Has_1_Right_Child()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            tree.Add(6);
            //Then
            Assert.Equal(new[] { 6, 4 }, tree.PostOrderTraversal());
        }
Esempio n. 4
0
        public void Test_PostOrderTraversal_Root_Has_2_Children()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            tree.Add(2);
            tree.Add(5);
            //Then
            Assert.Equal(new[] { 5, 4, 2 }, tree.PostOrderTraversal());
        }
Esempio n. 5
0
        public void Test_Add_Method_For_Edge_Case()
        {
            //Given
            var tree = new BinaryTreeCollection <int>
            {
                5,
                2,
                6,
                4,
                3
            };

            //Then
            Assert.Equal(new[] { 6, 5, 4, 3, 2 }, tree.PostOrderTraversal());
            Assert.Equal(new[] { 2, 3, 4, 5, 6 }, tree.InOrderTraversal());
        }