Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            BinaryTree bt = new BinaryTree(50);

            bt.head.Left       = new Node(20);
            bt.head.Left.Left  = new Node(5);
            bt.head.Left.Right = new Node(25);
            bt.head.Right      = new Node(70);
            bt.PrintTree();
            Console.WriteLine("*************************************");
            bt.add(30);
            bt.add(85);
            bt.add(17);
            bt.PrintTree();
            Console.WriteLine("*************************************");
            Console.WriteLine(bt.GetMax());
            Console.WriteLine(bt.GetMax2());
            Console.WriteLine(bt.GetMin());
            Console.WriteLine(bt.Find(30).Value);
            Console.WriteLine(bt.Find2(25).Value);
            Console.WriteLine(bt.Delete(700));
            Console.WriteLine(bt.Delete(30));
            bt.PrintTree();
            Console.WriteLine("NOTICE!!!!! the value : '30' has been deleted !");
            Console.WriteLine(bt.Delete(20));
            bt.PrintTree();
            Console.WriteLine("NOTICE!!!!! the value : '20' CANOT be deleted !");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            BinaryTree <int> binaryTree = new BinaryTree <int>();

            binaryTree.Insert(60);
            binaryTree.Insert(35);
            binaryTree.Insert(76);
            binaryTree.Insert(42);
            binaryTree.Insert(17);
            binaryTree.Insert(68);
            binaryTree.Insert(11);
            binaryTree.Insert(24);
            binaryTree.Insert(63);
            binaryTree.Insert(69);
            binaryTree.Insert(23);

            binaryTree.Delete(35);
            binaryTree.InOrder(binaryTree.Root);

            //binaryTree.Insert(50);
            //binaryTree.Insert(75);
            //binaryTree.Insert(93);
            //binaryTree.Insert(87);
            //binaryTree.Insert(62);

            //binaryTree.Delete(75);
            //binaryTree.InOrder(binaryTree.Root);

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            BinaryTree bt = new BinaryTree();

            bt.Add("Jesse");
            bt.Add("Calum");
            bt.Add("Nathan");
            bt.Add("Travis");
            bt.Add("Inarius");
            bt.Add("Bundo");
            bt.Add("Balgour");
            bt.Add("Hughug");
            bt.Add("Jessica");
            bt.Add("Lucy");



            bt.Display();
            Console.WriteLine();
            string choice = DisplayMenu();

            Console.WriteLine();
            do
            {
                switch (choice)
                {
                case "A":
                    bt.Add(NewItem());
                    break;

                case "D":
                    bt.Delete(DeleteItem());
                    break;

                case "F":
                    bt.SearchItem(SearchItem());
                    break;

                default: break;
                }
                if (choice != "Q")
                {
                    bt.Display();
                    Console.WriteLine();
                    choice = DisplayMenu();
                    Console.WriteLine();
                }
            }while (choice != "Q");
        }