Beispiel #1
0
        static void Main(string[] args)
        {
            //BinTree t = new BinTree(15);
            //t.Add(20);
            //t.Add(25);
            //t.Add(35);
            //t.Add(256);
            //t.PreFixLeft(t.Head);
            //Console.WriteLine("\n------");
            //t.PreFixRight(t.Head);

            //LinkedList l = new LinkedList(10);
            //l.RemoveTail();
            //l.PrintList();

            //Queue q = new Queue();
            //q.Enqueue(4);
            //q.Enqueue(8);
            //q.Enqueue(16);
            //q.Enqueue(66);
            //q.PrintQueue();
            //q.Dequeue();
            //q.PrintQueue();

            //Stack s = new Stack(10);
            //s.PrintStack();
            //s.Push(20);
            //s.Push(32);
            //s.PrintStack();
            //s.Pop();
            //s.PrintStack();

            BST bt = new BST(10);

            bt.Add(9);
            bt.Add(17);
            bt.Add(20);
            bt.Add(8);

            Console.WriteLine(bt.Head.Right.Value);

            //Implement tree view
        }
Beispiel #2
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();
        }