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); }
void Insert() { int value = Convert.ToInt32(input_Insert.text); intTree.Insert(value); RefreshOutput(); }
public void BinarySearchTree_01_Insert_03_After1Insert_HeightEquals0() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntEmpty(); int expected = 0; // Act tree.Insert(3); int actual = tree.Height(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_01_Insert_02_After1Insert_SizeEquals1() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntEmpty(); int expected = 1; // Act tree.Insert(3); int actual = tree.Size(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_01_Insert_01_After1Insert_IsEmptyReturnsFalse() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntEmpty(); bool expected = false; // Act tree.Insert(3); bool actual = tree.IsEmpty(); // Assert Assert.AreEqual(expected, actual); }
private IBinarySearchTree <TLabel> CreateTree(IEnumerable <TLabel> values) { IBinarySearchTree <TLabel> tree = null; foreach (var value in values) { if (tree == null) { tree = this.CreateTree(value); } else { tree.Insert(value); } } return(tree); }
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 virtual void Insert_DuplicateInMiddle_OfFourNodesRightRight() { FourNodesRightRight.Insert(75); }
public virtual void Insert_DuplicateInMiddle_OfFourNodesLeftLeft() { FourNodesLeftLeft.Insert(25); }
public virtual void Insert_DuplicateAtRoot_OfThreeNodesFull() { ThreeNodesFull.Insert(50); }
public virtual void Insert_ThirdNode_IntoRootRight() { RootRight.Insert(25); Assert.AreEqual <int>(3, RootRight.Count); }
public virtual void Insert_IntoRootOnly_Smaller() { RootOnly.Insert(25); Assert.AreEqual <int>(2, RootOnly.Count); }
public virtual void Insert_IntoEmpty() { Empty.Insert(50); Assert.AreEqual <int>(1, Empty.Count); }