public void BuildTree_FromPreOrderSequence_ReturnsCorrectBinarySearchTree() { 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 }); Assert.That(tree.IsBinarySearchTree(), Is.True); }
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 })); }
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 })); }
public void BuildTree_FromPreOrderSequenceOnTestData_ReturnsCorrectBinarySearchTree() { BinaryTree <int> tree = PreOrderTreeWalkerBuilder.Build(PreOrderTreeTestDataBuilder.GetTreeInPreOrder()); Assert.That(tree.IsBinarySearchTree(), Is.True); }