Ejemplo n.º 1
0
        public static void Main()
        {
            BinarySearchTree nums = new BinarySearchTree();

            nums.Insert(23);
            nums.Insert(45);
            nums.Insert(16);
            nums.Insert(37);
            nums.Insert(3);
            nums.Insert(99);
            nums.Insert(22);
            Console.WriteLine("Inorder traversal: ");
            nums.InOrder(nums.root);
            Console.WriteLine("Minimum value is " + nums.FindMin());
            Console.WriteLine("Maximum value is " + nums.FindMax());
            bool found = nums.Find(43) != null;

            Console.WriteLine("43 node is present: " + found);
            Console.WriteLine("45 node is present: " + (nums.Find(45) != null));
            Console.WriteLine("3 node is present: " + (nums.Find(3) != null));
            Console.WriteLine("23 node is present: " + (nums.Find(23) != null));
            Console.WriteLine("29 node is present: " + (nums.Find(29) != null));
            Console.WriteLine("99 node is present: " + (nums.Find(99) != null));
            nums.Delete(45);
        }