예제 #1
0
        static void Main(string[] args)
        {
            AVLTree<int> tree = new AVLTree<int>();
            tree.Add(50);
            tree.Add(2);
            tree.Add(7);
            tree.Add(94);
            tree.Add(24);
            tree.Add(24);
            tree.Add(71);
            tree.Add(30);
            tree.Add(49);
            Console.WriteLine("Count: " + tree.count()); // Should be 9
            Console.WriteLine("Min: " + tree.min()); // Should be 2
            Console.WriteLine("Max: " + tree.max()); // Should be 94
            Console.WriteLine("Depth: " + tree.depth()); // Should be 7
            tree.print(); // Prints the values in order

            tree.Remove(49); // test for value not in tree
            tree.Remove(51); // test for value not in tree
            tree.Remove(50);
            tree.Remove(2);
            tree.Remove(7);
            tree.Remove(94);
            tree.Remove(24);
            tree.Remove(24);
            tree.Remove(71);
            tree.Remove(30);
            tree.Remove(49);
            Console.WriteLine("Count: " + tree.count()); // Should be 0
            Console.WriteLine("Min: " + tree.min()); // Should be -1
            Console.WriteLine("Max: " + tree.max()); // Should be -1
            Console.WriteLine("Depth: " + tree.depth()); // Should be 0
            tree.print(); // Prints the values in order
        }