public void Remove_TheRootElementWithBothChild_NewRootIsTheRightChild() { var firstNode = 2; var secondNode = 1; var thirdNode = 3; var bst = new BinarySearchTree <int, int>(); bst.Insert(Key(firstNode), Value(firstNode)); bst.Insert(Key(secondNode), Value(secondNode)); bst.Insert(Key(thirdNode), Value(thirdNode)); bst.Remove(Key(firstNode)); NodeAssert.NotNullAndEqual(bst.Root, Node(thirdNode)); NodeAssert.RightChildIsNull(bst.Root); }
public void Remove_TheLeftChildWithRightChild_TheRootWithWithLeftChild() { var firstNode = 4; var secondNode = 2; var thirdNode = 3; var bst = new BinarySearchTree <int, int>(); bst.Insert(Key(firstNode), Value(firstNode)); bst.Insert(Key(secondNode), Value(secondNode)); bst.Insert(Key(thirdNode), Value(thirdNode)); bst.Remove(Key(secondNode)); NodeAssert.NotNullAndEqual(bst.Root, Node(firstNode)); NodeAssert.NotNullAndEqual(bst.Root.Left, Node(thirdNode)); NodeAssert.RightChildIsNull(bst.Root); }