Exemple #1
0
        public void PostOrder3()
        {
            //Arrange
            Node node = new Node();

            // Declare and populate the nodes
            Node node1 = new Node()
            {
                Value = 1
            };
            Node node2 = new Node()
            {
                Value = 2
            };
            Node node3 = new Node()
            {
                Value = 3
            };

            // Instantiate the tree
            MyTree tree = new MyTree(node);

            // Link the tree
            node1.LeftChild  = node2;
            node1.RightChild = node3;

            Assert.Equal(" 2 2 3 1", MyTree.PostOrder(node1, ""));
        }
Exemple #2
0
        public void PostOrder1()
        {
            //Arrange
            Node node = new Node();

            // Declare and populate the nodes
            Node node1 = new Node()
            {
                Value = 1
            };
            Node node2 = new Node()
            {
                Value = 2
            };
            Node node3 = new Node()
            {
                Value = 3
            };
            Node node4 = new Node()
            {
                Value = 4
            };
            Node node5 = new Node()
            {
                Value = 5
            };
            Node node6 = new Node()
            {
                Value = 6
            };
            Node node7 = new Node()
            {
                Value = 7
            };

            // Instantiate the tree
            MyTree tree = new MyTree(node);

            // Link the tree.
            node1.LeftChild  = node2;
            node1.RightChild = node3;

            node2.LeftChild  = node4;
            node2.RightChild = node5;

            node3.LeftChild  = node6;
            node3.RightChild = node7;


            Assert.Equal(" 4 4 5 2 4 4 5 2 4 4 5 2 6 4 4 5 2 4 4 5 2 6 7 3 1", MyTree.PostOrder(node1, ""));
        }
Exemple #3
0
        public void PostOrder2()
        {
            //Arrange
            Node node = new Node();

            // Declare and populate the nodes
            Node node1 = new Node()
            {
                Value = 1
            };

            // Instantiate the tree
            MyTree tree = new MyTree(node);

            Assert.Equal(" 1", MyTree.PostOrder(node1, ""));
        }