Example #1
0
        public void ShouldPerformALimitedDepthSearchSuccessfully()
        {
            int maxDepth       = 3;
            var binaryTreeUtil = new BinaryTreeUtil();
            var result         = binaryTreeUtil.MaxDepthSearch(CreateValidBinaryTree(), 4, maxDepth, 0);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.NodeValue == 4);
        }
Example #2
0
        public void ShouldOnlySearch1LevelDeepAndReturnNull()
        {
            int maxDepth       = 2;
            int currentDepth   = 0;
            var binaryTreeUtil = new BinaryTreeUtil();
            var tree           = CreateValidBinaryTree();

            var result = binaryTreeUtil.MaxDepthSearch(tree, 4, maxDepth, currentDepth);

            Assert.IsNull(result);
        }