public static void RBT_Tester(int[] data) { BST tree = new RBT(); tree.Insert(data); //tree.InOrderPrint(); //tree.PreOrderPrint(); //tree.PostOrderPrint(); tree.Delete(5); tree.InOrderPrint(); tree.Delete(10); tree.InOrderPrint(); tree.Delete(3); tree.InOrderPrint(); }
public void HeightTest() { RBT <int, int> rbt = new RBT <int, int>(); for (int i = 0; i < 10; i++) { rbt.Insert(i + 1, i + 1); rbt.Delete(rbt.Search_(i + 1)); } int height = rbt.MaxHeight(); height = rbt.MinHeight(); height = rbt.BlackHeight(); Console.WriteLine(height); }
public void AddAndRemove() { var value1 = 1; var value2 = 2; var value3 = 3; var tree = new RBT <string, int>(); tree.Insert(value3.ToString(), value3); tree.Insert(value1.ToString(), value1); tree.Insert(value2.ToString(), value2); CollectionAssert.AreEqual(new List <int> { 1, 2, 3 }, tree.IncoderTreeWalk()); tree.Delete(value3.ToString()); CollectionAssert.AreEqual(new List <int> { 1, 2 }, tree.IncoderTreeWalk()); }