Пример #1
0
 public BST()
 {
     Root = Root == null ? this : Root;
 }
Пример #2
0
        public BST(int val)
        {
            this.Value = val;

            Root = Root == null ? this : Root;
        }
Пример #3
0
        static void Main01(string[] args)
        {
            MainNEW(args);
            BitArray bitArr = new BitArray(int.MaxValue);

            CallTryCatch();
            //[67108864]

            //    Car[] cars = new Car[2];
            //    cars[0] = new Car("Nissan");
            //    cars[1] = new Car("Toyota");

            //    Swap(cars[0], cars[1]);
            // no change in array.


            BST binaryTree = new BST();

            //binaryTree.CreateTree(4);
            //int[] arr = new int[] { 2, 5, 1, 3, 7, 6, 9 };

            binaryTree.CreateTree(9);
            int[] arr = new int[] { 4, 14, 2, 5, 10, 1, 3, 7, 12, 6, 8, 11, 13 };

            foreach (int x in arr)
            {
                binaryTree.InsertNode(x);
            }

            binaryTree.PrintInorder();

            Console.WriteLine(binaryTree.Add('a', 'b'));
            Console.WriteLine("Now print PreOrder Ittv....");
            Console.WriteLine();
            binaryTree.PrintTree_PreOrder_Ittv(binaryTree.Root);

            binaryTree.PrintTree_InOrder_Ittv(binaryTree.Root);


            Console.WriteLine("Now print PostOrder Ittv....");
            Console.WriteLine();
            binaryTree.PrintTree_PostOrder_Ittv(binaryTree.Root);


            int i = 5;

            Console.WriteLine(i = i << 5);
            Console.WriteLine(i = i << 5);

            bool ss = CheckHasUniqueCharsUsingBitwise("abcdefghij");


            IntBuffer buff = new IntBuffer(4);
            Producer  p    = new Producer(buff);
            Consumer  c    = new Consumer(buff);

            Thread producer = new Thread(new ThreadStart(p.Run));
            Thread consumer = new Thread(new ThreadStart(c.Run));

            producer.Start();
            consumer.Start();
        }
Пример #4
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write("\n\t1.Linked List\n\t2.Stack Array\n\t3.Stack Linked List\n\t4.Postfix\n\t5.Infix to Postfix");
                Console.Write("\n\t6.Hash Table\n\t7.Binary Tree\n\t8.Sorting\n\t9.Threaded Binary Tree\n\t10.Binary Tree");
                Console.Write("\n\t11.Heap\n\t0:Exit\nEnter Choice: ");
                var input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    MyLinkedList <object> .Demo();

                    break;

                case "2":
                    StackArray <int> .Demo();

                    break;

                case "3":
                    StackLinkList <object> .Demo();

                    break;

                case "4":
                    Postfix.Demo();
                    break;

                case "5":
                    Postfix.InfixToPostfix();
                    break;

                case "6":
                    HashTable.Demo();
                    break;

                case "7":
                    BST.Demo();
                    break;

                case "8":
                    Sorting.Demo();
                    break;

                case "9":
                    ThreadedBinaryTree.Demo();
                    break;

                case "10":
                    BinaryTree.Demo();
                    break;

                case "11":
                    Heap.Demo();
                    break;

                case "0":
                    return;
                }
            }
        }
Пример #5
0
 public void FindMax()
 {
     Console.WriteLine($"Maximum: {BST.FindMax(this.Root)}");
 }
Пример #6
0
 public void FindMin()
 {
     Console.WriteLine($"Minimum: {BST.FindMin(this.Root)}");
 }