Beispiel #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 !");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var        binaryTree = new BinaryTree <int>();
            FileStream stream     = new FileStream(@".\text.txt", FileMode.Open, FileAccess.Read);

            byte[] data = new byte[stream.Length];

            stream.Read(data, 0, data.Length);

            string          s       = Encoding.UTF8.GetString(data);
            Regex           reg     = new Regex(@"[а-яА-Я]+");
            MatchCollection matches = reg.Matches(s);


            binaryTree.PrintTree();


            Console.ReadLine();
        }