Ejemplo n.º 1
0
        static void TestBinarySearchTree()
        {
            BinarySearchTree bs = new BinarySearchTree();

            bs.Put(18, "S"); //6
            bs.Put(5, "E");  //2
            bs.Put(3, "A");  //0
            bs.Put(15, "R"); ///5
            bs.Put(4, "C");  //1
            bs.Put(9, "H");  //3
            bs.Put(23, "X"); //7
            bs.Put(10, "M"); //4
            bs.Put(12, "P"); //5
            bs.Put(6, "L");
            //Console.WriteLine(bs.Size());
            //Console.WriteLine(bs.Rank(5));//2
            //Console.WriteLine(bs.Rank(19));
            Console.WriteLine(bs.RangeCount(5, 18));
            bs.RangeValues(5, 18);
            Console.WriteLine(bs.RangeCount(5, 19));
            bs.RangeValues(5, 19);
            //Console.WriteLine(bs.RangeCount(6, 18));
            //bs.RangeValues(6, 18);
            //Console.WriteLine(bs.RangeCount(6, 19));
            //bs.RangeValues(6, 19);
            //var a = bs.Iterator();
            //foreach (var item in a)
            //{
            //    Console.WriteLine(bs.Get(item));
            //}

            //Console.WriteLine(bs.Get(5));
            //bs.DeleteMinimum();
            //Console.WriteLine((bs.Min()).Value);
            //bs.DeleteMinimum();
            //Console.WriteLine((bs.Min()).Value);
            //Console.WriteLine(bs.Get(10));
        }