Ejemplo n.º 1
0
        public void TestFirstCase()
        {
            var tree   = new TreeNode(1, new TreeNode(2, new TreeNode(3), new TreeNode(4)), new TreeNode(2, new TreeNode(4), new TreeNode(3)));
            var sol    = new SymmetricTree(tree);
            var result = sol.IsSymmetricOne();

            Assert.True(result);
        }
Ejemplo n.º 2
0
        public void TestThirdCase_2()
        {
            var tree   = new TreeNode(1);
            var sol    = new SymmetricTree(tree);
            var result = sol.IsSymmetricTwo();

            Assert.True(result);
        }
Ejemplo n.º 3
0
        public void TestSecondCase_2()
        {
            var tree = new TreeNode(1, new TreeNode(2, left: null, right: new TreeNode(3)),
                                    new TreeNode(2, left: null, right: new TreeNode(3)));
            var sol    = new SymmetricTree(tree);
            var result = sol.IsSymmetricTwo();

            Assert.False(result);
        }
Ejemplo n.º 4
0
        public bool IsSymmetric(TreeNode root)
        {
            var res = new SymmetricTree(root);

            return(res.IsSymmetricTwo());
        }