static void Main(string[] args)
        {
            BST tree = new BST();

            tree.Add(5);
            tree.Add(2);
            tree.Add(34);
            tree.Add(18);
            tree.Add(55);
            tree.Add(1);
            tree.Add(3);
            tree.Add(-1);
            tree.Add(-2);
            tree.Add(6);
            tree.Add(7);
            tree.Print();
            //Console.WriteLine(tree.Search(2));
            //Console.WriteLine(tree.Search(100));

            //Console.WriteLine("PreOrder Traversal");
            //tree.PreOrder(tree.root);
            //Console.WriteLine("\nInOrder Traversal");
            //tree.InOrder(tree.root);
            //Console.WriteLine("\nPostOrder Traversal");
            //tree.PostOrder(tree.root);
            //Console.WriteLine("\nLevelOrder Traversal");
            //tree.LevelOrder(tree.root);

            //Console.WriteLine("\nFormat & Print LevelOrder Traversal");
            //tree.LevelOrderPrint(tree.root);

            Console.WriteLine("\nPrint Reverse LevelOrder Traversal");
            tree.LevelOrderReversePrint(tree.root);


            //Node minValue = tree.MinValueBST(tree.root);
            //Console.WriteLine("\nMin Value of BST is {0}", minValue.Data);

            //Node maxValue = tree.MaxValueBST(tree.root);
            //Console.WriteLine("\nMax Value of BST is {0}", maxValue.Data);

            //int heightBST = tree.HeightBST(tree.root);
            //Console.WriteLine("\nHeight of the BST is {0}", heightBST);

            //int sizeBST = tree.SizeBST(tree.root);
            //Console.WriteLine("\nSize of the BST is {0}", sizeBST);

            //Console.WriteLine("\nBefore Deleting");
            //tree.Print();

            //Console.WriteLine("\nAfter Deleting");
            //tree.Delete(34);
            //tree.Print();
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            BST tree = new BST();

            tree.Add(20);
            tree.Add(15);
            tree.Add(17);
            tree.Add(30);
            tree.Add(34);
            tree.Add(32);
            tree.Add(10);
            tree.Add(12);
            CheckTree(tree);
            Console.WriteLine("***-*-*-*-*-*-*-***");
            tree.Print();
            tree.Remove(tree.GetNode(15));
            CheckTree(tree);
            Console.WriteLine("***-*-*-*-*-*-*-***");
            tree.Print();
            Console.ReadLine();
        }