public void Int_Inorder_CustomBinaryTree_With_IComparer() { var comparer = new IntComparator(); var newTree = new BinarySearchTree <int>(comparer); newTree.Add(inputArray); var helperArrayResult = new int[7] { 1, 3, 4, 5, 6, 8, 9 }; var index = 0; foreach (int item in newTree.Inorder()) { Assert.AreEqual(helperArrayResult[index++], item); } }
public void Int_Preorder_CustomBinaryTree_With_Comparison() { var comparer = new IntComparator(); Comparison <int> comparison = comparer.Compare; var newTree = new BinarySearchTree <int>(comparison); newTree.Add(inputArray); var helperArrayResult = new int[7] { 5, 3, 1, 4, 8, 6, 9 }; var index = 0; foreach (int item in newTree) { Assert.AreEqual(helperArrayResult[index++], item); } }
public void Int_Postorder_CustomBinaryTree_With_Comparison_Null() { var comparer = new IntComparator(); Comparison <int> comparison = null; var newTree = new BinarySearchTree <int>(comparison); newTree.Add(inputArray); var helperArrayResult = new int[7] { 1, 4, 3, 6, 9, 8, 5 }; var index = 0; foreach (int item in newTree.Postorder()) { Assert.AreEqual(helperArrayResult[index++], item); } }