public void OS_Rank_AfterDeletingTest() { RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess(); int NUMBER = 1000; int HALF = NUMBER / 2; for (int i = 0; i < NUMBER; i++) { tree.RB_Insert(i); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Delete(i); } for (int i = 0; i < HALF; i++) { Assert.AreEqual(i, tree.OS_Rank(i)); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Insert(i); } for (int i = 0; i < NUMBER; i++) { Assert.AreEqual(i, tree.OS_Rank(i)); } }
public void InsertingAfterDeletingTest1() { RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess(); int NUMBER = 6; int HALF = NUMBER / 2; for (int i = 0; i < NUMBER; i++) { tree.RB_Insert(i); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Delete(i); } int test = tree.SearchForIndex(4); if (test.Equals(4)) { Assert.Fail("test.Key == 4"); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Insert(i); } //RBNode testNode = tree.GetMinimum(); //Assert.AreEqual( 0, testNode.Key ); for (int i = 0; i < NUMBER; i++) { Assert.AreEqual(i, tree.OS_Rank(i)); //testNode = tree.GetSuccessor( testNode ); } }
public void InsertingAfterDeletingTest1000() { RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess(); int NUMBER = 1000; int HALF = NUMBER / 2; for (int i = 0; i < NUMBER; i++) { tree.RB_Insert(i); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Delete(i); } for (int i = HALF; i < NUMBER; i++) { tree.RB_Insert(i); } //RBNode testNode = tree.GetMinimum(); //Assert.AreEqual( 0, testNode.Key ); for (int i = 0; i < NUMBER; i++) { Assert.AreEqual(i, tree.OS_Rank(i)); //testNode = tree.GetSuccessor( testNode ); } }
public void OS_Rank_Test() { RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess(); for (int i = 0; i < 1000; i++) { tree.RB_Insert(i); } for (int i = 0; i < 1000; i++) { Assert.AreEqual(i, tree.OS_Rank(i)); } }