Exemple #1
0
        static void Main(string[] args)
        {
            BST tree = new BST(new Node(10));

            tree.DeleteKey(10);
//            tree.Minimum();
            tree.Insert(30);
            Console.WriteLine(tree.Minimum().Key);

//            tree.Insert(20);
//            tree.Insert(30);
//            tree.Insert(5);
//            tree.Insert(7);
//            tree.InOrderTreeWalk();
//            Console.WriteLine(tree.Minimum().Key);

//            Node nodeToSearch = tree.Search(20);
//            if (nodeToSearch == null)
//            {
//                Console.WriteLine("Didn't find the element");
//            }
//            else
//            {
//                Console.WriteLine("Find the node");
//            }
//            tree.DeleteKey(30);
//            Node nodeToSearchAgain = tree.Search(20);
//            if (nodeToSearchAgain == null)
//            {
//                Console.WriteLine("Didn't find the element");
//            }
//            else
//            {
//                Console.WriteLine("Find the node");
//            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("---------Welcome To Binary Search Tree--------");
            Console.WriteLine();
            BST <int> bST = new BST <int>(56);

            bST.Insert(30);
            bST.Insert(70);
            bST.Insert(22);
            bST.Insert(40);
            bST.Insert(60);
            bST.Insert(95);
            bST.Insert(11);
            bST.Insert(65);
            bST.Insert(3);
            bST.Insert(16);
            bST.Insert(63);
            bST.Insert(67);

            bST.GetSize();
            bST.Display();
            bool result = bST.Search(63, bST);

            Console.WriteLine();
            Console.WriteLine("The element 63 exists in the BST: " + bST.Search(63, bST));

            Console.Read();
        }