示例#1
0
        static void Main(string[] args)
        {
            RBTree <int, string> map = new RBTree <int, string>(CompINT);

            map.Add(1, "a");
            map.Add(3, "c");
            map.Add(4, "c");
            map.Add(2, "c");
            map.Delete(4);
            Console.WriteLine(map[8]);
        }
示例#2
0
        static void Main(string[] args)
        {
            RBTree <int, string> tree = new RBTree <int, string>(CompINT);

            tree.Add(1, "a");
            tree.Add(3, "c");
            tree.Add(4, "c");
            tree.Add(2, "c");
            tree.Delete(4);
            Console.WriteLine(tree[8]);
        }
示例#3
0
        static void Main(string[] args)
        {
            RBTree <int> tree = new RBTree <int>();

            tree.Add(30);
            tree.Add(91);
            tree.Add(19);
            tree.Add(76);
            tree.Add(40);
            tree.Add(71);
            tree.Add(8);
            tree.Add(99);
            tree.Add(90);
            tree.Add(21);
        }
示例#4
0
        //Постройте красно-черное дерево по заданным ключам
        //Реализуйте красно-черное дерево со следующими операциями:

        //создание дерева
        //добавление элемента
        //поиск элемента в дереве
        //14. Vector(53, 38, 65, 98, 38, 76, 4, 28, 14, 33, 25, 21, 54, 58, 32, 25, 63, 63, 94, 1, 86)
        static void Main(string[] args)
        {
            int[] vector = new int[] { 53, 38, 65, 98, 38, 76, 4, 28, 14, 33, 25, 21, 54, 58, 32, 25, 63, 63, 94, 1, 86 };

            RBTree <int> tree   = new RBTree <int>(new Node <int>(vector[0]));
            Random       random = new Random();

            for (int i = 1; i < vector.Length; i++)
            {
                tree.Add(vector[i]).data = random.Next(10, 100);
            }

            Console.WriteLine("Item 54 has " + tree.Find(54, tree.root).data.ToString() + " value in data");
            Console.ReadLine();
        }