예제 #1
0
        public void RecursivePartialLeaves()
        {
            //           3
            //         /   \
            //        9     20
            //       /       \
            //      15        7
            //                 \
            //                  12

            var testNode = new BinaryTreeNode <int>(3)
            {
                Left  = new BinaryTreeNode <int>(9),
                Right = new BinaryTreeNode <int>(20)
            };

            testNode.Left.Left = new BinaryTreeNode <int>(15);

            testNode.Right.Right = new BinaryTreeNode <int>(7)
            {
                Right = new BinaryTreeNode <int>(12)
            };

            var expected = 4;
            var actual   = BinaryTreeDepth.RecursiveDepthFirstSearch(testNode);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void RecursiveFullLeaves()
        {
            //           3
            //         /   \
            //        9     20

            var testNode = new BinaryTreeNode <int>(3)
            {
                Left  = new BinaryTreeNode <int>(9),
                Right = new BinaryTreeNode <int>(20)
            };

            var expected = 2;
            var actual   = BinaryTreeDepth.RecursiveDepthFirstSearch(testNode);

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
 public void RecursiveNullRef()
 {
     Assert.AreEqual(-1, BinaryTreeDepth.RecursiveDepthFirstSearch(null));
 }