Exemplo n.º 1
0
        public void FindSumPath_ForTestData_ReturnRightPath()
        {
            BinaryTree <int> tree = PreOrderTreeWalkerBuilder.Build(PreOrderTreeTestDataBuilder.GetTreeInPreOrder());

            SumPathFinder finder = new SumPathFinder(tree);

            List <int> path = finder.FindPath(1940);

            Assert.That(path, Is.EqualTo(new [] { 490, 258, 366, 424, 402 }));
        }
Exemplo n.º 2
0
        public void FindSumPath_For8_ReturnRightPath()
        {
            BinaryTree <int> tree = PreOrderTreeWalkerBuilder.Build(new[]
            {
                1, 4, 6, 10, 0, 0, 0, 7, 0, 8, 0, 0, 2, 5, 0, 0, 3, 9, 0, 0, 0
            });

            SumPathFinder finder = new SumPathFinder(tree);

            List <int> path = finder.FindPath(8);

            Assert.That(path, Is.EqualTo(new [] { 8 }));
        }