Beispiel #1
0
        public static void QueueFunctions()
        {
            QueueAsArray <int> queue = new QueueAsArray <int>(4);

            queue.enqueue(10);
            queue.enqueue(20);
            queue.enqueue(30);
            queue.enqueue(40);

            Console.WriteLine("Front Item : " + queue.frontItem());
            Console.WriteLine("Last Item : " + queue.rearItem());

            Console.WriteLine("Dequeued item: " + queue.dequeue());


            QueueAsLinkedList queueList = new QueueAsLinkedList();

            queueList.enqueue(10);
            queueList.enqueue(20);
            queueList.enqueue(30);
            queueList.enqueue(40);

            Console.WriteLine("Dequeued Item: " + queueList.dequeue().key);

            queue.generateBinary(10);
        }
Beispiel #2
0
        public void generateBinary(int n)
        {
            QueueAsArray <string> queue = new QueueAsArray <string>(n);

            queue.enqueue("1");

            while (n-- > 0)
            {
                string s1 = queue.frontItem();

                Console.WriteLine(queue.dequeue());
                string s2 = s1;
                queue.enqueue(s1 + "0");
                queue.enqueue(s2 + "1");
            }
        }