Esempio n. 1
0
        static void Main(string[] args)
        {
            CAppMyBinTree.Check();

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
        /// <summary>
        ///
        /// </summary>
        public static void Check()
        {
            CAppMyBinTree tmpTree = new CAppMyBinTree();

            tmpTree.Insert(-20);
            for (int i = 0; i < 20; i++)
            {
                tmpTree.Insert(i);
                tmpTree.Insert(i + 1);
                tmpTree.Insert(i + 2);
            }

            Console.WriteLine("Content of bin tree");
            tmpTree.Print();

            int t = 20;

            Console.WriteLine("Item {0} in the three: {1}", t, tmpTree.Find(t));

            t = -20;
            Console.WriteLine("Item {0} in the three: {1}", t, tmpTree.Find(t));
            Console.WriteLine("BST : {0}", tmpTree.CheckIfBST());
            Console.WriteLine("Minimum element: {0}", tmpTree.FindMin());
            Console.WriteLine("-----------------------------------------");
            tmpTree.CreateDummyTree();
            Console.WriteLine("Content of bin tree");
            tmpTree.Print();

            Console.WriteLine("-----------------------------------------");
            CAppMyBinTree tmp1 = new CAppMyBinTree();

            //tmp1.Insert(10);
            //tmp1.Insert(9);
            //tmp1.Insert(11);
            //tmp1.Insert(1);
            //tmp1.Insert(50);
            //tmp1.Insert(12);
            //tmp1.Insert(15);
            tmp1.InsertRec(tmp1.m_root, 1, 3);
            Console.WriteLine(tmp1.m_root.DisplayNode());
        }