public void BinarySearchTree_01_Insert_07_After13UnorderedInserts_ToInfixStringCorrect() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntEmpty(); string expected = "[ [ NIL 3 [ [ NIL 7 NIL ] 8 [ NIL 12 NIL ] ] ] 17 [ [ NIL 24 NIL ] 26 [ NIL 32 [ [ NIL 34 [ [ NIL 37 NIL ] 42 NIL ] ] 45 [ NIL 50 NIL ] ] ] ] ]"; // Act tree.Insert(17); tree.Insert(3); tree.Insert(26); tree.Insert(8); tree.Insert(24); tree.Insert(32); tree.Insert(7); tree.Insert(12); tree.Insert(45); tree.Insert(34); tree.Insert(50); tree.Insert(42); tree.Insert(37); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_04_Remove_06_OnNonEmptyTree_ElementWithBothChilds() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); string expected = "[ [ NIL 3 [ [ NIL 7 NIL ] 8 [ NIL 12 NIL ] ] ] 17 [ [ NIL 24 NIL ] 26 [ [ NIL 34 [ [ NIL 37 NIL ] 42 NIL ] ] 45 [ NIL 50 NIL ] ] ] ]"; // Act tree.Remove(32); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_03_RemoveMin_04_OnModerateIntTree() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); string expected = "[ [ [ NIL 7 NIL ] 8 [ NIL 12 NIL ] ] 17 [ [ NIL 24 NIL ] 26 [ NIL 32 [ [ NIL 34 [ [ NIL 37 NIL ] 42 NIL ] ] 45 [ NIL 50 NIL ] ] ] ] ]"; // Act tree.RemoveMin(); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_03_RemoveMin_03_OnSmallIntTree() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntSmall(); string expected = "[ [ NIL 4 [ NIL 5 NIL ] ] 6 [ NIL 7 NIL ] ]"; // Act tree.RemoveMin(); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_03_RemoveMin_02_OnTree1Element() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeInt1Element(); string expected = "NIL"; // Act tree.RemoveMin(); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_01_Insert_06_After3UnorderedInserts_ToInfixStringCorrect() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntEmpty(); string expected = "[ [ NIL 1 NIL ] 2 [ NIL 3 NIL ] ]"; // Act tree.Insert(2); tree.Insert(1); tree.Insert(3); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }