public void OrderStatisticTreeTests_GetRank() { IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>(); var actualRank = tree.GetRank(null); Assert.IsTrue(actualRank == -1); }
public void OrderStatisticTreeTests_GetRank() { IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>(); var actualRank = tree.GetRank(null); Assert.IsTrue(actualRank == -1); }
public void OrderStatisticTreeTests_GetRank2() { IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>(); tree.Insert(10, "John"); tree.Insert(5, "Clark"); var node = tree.Insert(13, "Pitty"); tree.Insert(17, "Lilly"); tree.Insert(8, "Jack"); tree.Insert(0, "Lui"); tree.Insert(16, "Petr"); var actualRank = tree.GetRank((IOrderStatisticTreeNode <int, string>)node); Assert.IsTrue(actualRank == 4); }
public void OrderStatisticTreeTests_Random_GetRank2() { Random r = new Random(); int n = r.Next(1000000) + 1; IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>(); for (int i = 0; i < n; i++) { int key = r.Next(int.MaxValue); tree.Insert(key, string.Empty); } var list = tree.TraverseInOrder().ToList(); for (int i = 0; i < n; i++) { var actualRank = tree.GetRank((IOrderStatisticTreeNode <int, string>)list[i]); Assert.AreEqual(actualRank, i); } }
public void OrderStatisticTreeTests_GetRank2() { IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>(); tree.Insert(10, "John"); tree.Insert(5, "Clark"); var node = tree.Insert(13, "Pitty"); tree.Insert(17, "Lilly"); tree.Insert(8, "Jack"); tree.Insert(0, "Lui"); tree.Insert(16, "Petr"); var actualRank = tree.GetRank((IOrderStatisticTreeNode<int, string>)node); Assert.IsTrue(actualRank == 4); }
public void OrderStatisticTreeTests_Random_GetRank2() { Random r = new Random(); int n = r.Next(1000000) + 1; IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>(); for (int i = 0; i < n; i++) { int key = r.Next(int.MaxValue); tree.Insert(key, string.Empty); } var list = tree.TraverseInOrder().ToList(); for (int i = 0; i < n; i++) { var actualRank = tree.GetRank((IOrderStatisticTreeNode<int, string>)list[i]); Assert.AreEqual(actualRank, i); } }