예제 #1
0
        public void MirrorTest5()
        {
            BinaryTreeNode node1 = null;

            BinaryTreeHelper.SetMirrorIteratively(node1);
            string completed = GetNodeString(node1);

            Assert.AreEqual(completed, null);
        }
예제 #2
0
        public void MirrorTest4()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(8);

            BinaryTreeHelper.SetMirrorIteratively(node1);
            string completed = GetNodeString(node1);

            Assert.AreEqual(completed, "8");
        }
예제 #3
0
        public void MirrorTest2()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(8);
            BinaryTreeNode node2 = new BinaryTreeNode(7);
            BinaryTreeNode node3 = new BinaryTreeNode(6);
            BinaryTreeNode node4 = new BinaryTreeNode(5);
            BinaryTreeNode node5 = new BinaryTreeNode(4);

            node1.leftChild = node2;
            node2.leftChild = node3;
            node3.leftChild = node4;
            node4.leftChild = node5;

            BinaryTreeHelper.SetMirrorIteratively(node1);
            string completed = GetNodeString(node1);

            Assert.AreEqual(completed, "87654");
        }
예제 #4
0
        public void MirrorTest1()
        {
            BinaryTreeNode node1 = new BinaryTreeNode(8);
            BinaryTreeNode node2 = new BinaryTreeNode(6);
            BinaryTreeNode node3 = new BinaryTreeNode(10);
            BinaryTreeNode node4 = new BinaryTreeNode(5);
            BinaryTreeNode node5 = new BinaryTreeNode(7);
            BinaryTreeNode node6 = new BinaryTreeNode(9);
            BinaryTreeNode node7 = new BinaryTreeNode(11);

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

            BinaryTreeHelper.SetMirrorIteratively(node1);
            string completed = GetNodeString(node1);

            Assert.AreEqual(completed, "810611975");
        }