示例#1
0
        public void FullBinaryTree()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(23);

            root.Left        = new BinaryTreeNode <int>(65);
            root.Right       = new BinaryTreeNode <int>(12);
            root.Left.Left   = new BinaryTreeNode <int>(98);
            root.Left.Right  = new BinaryTreeNode <int>(45);
            root.Right.Left  = new BinaryTreeNode <int>(112);
            root.Right.Right = new BinaryTreeNode <int>(111);

            Assert.Equal("23,12,65,98,45,112,111", PrintBinaryTreeZigZag.Print(root));
        }
示例#2
0
        public void NormalBinaryTree()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(23);

            root.Left              = new BinaryTreeNode <int>(65);
            root.Right             = new BinaryTreeNode <int>(12);
            root.Left.Left         = new BinaryTreeNode <int>(98);
            root.Right.Left        = new BinaryTreeNode <int>(112);
            root.Right.Right       = new BinaryTreeNode <int>(111);
            root.Right.Right.Right = new BinaryTreeNode <int>(236);
            root.Right.Right.Left  = new BinaryTreeNode <int>(239);

            Assert.Equal("23,12,65,98,112,111,236,239", PrintBinaryTreeZigZag.Print(root));
        }
示例#3
0
 public void InvalidInput()
 {
     Assert.Throws <ArgumentNullException>(() => PrintBinaryTreeZigZag.Print(null));
 }
示例#4
0
        public void BinaryTreeThatContainsOnlyOneNode()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(23);

            Assert.Equal("23", PrintBinaryTreeZigZag.Print(root));
        }