## Queues

 Question 1
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efﬁciently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)?
 A Both operations can be performed in O(1) time B At most one operation can be performed in O(1) time but the worst case time for the other operation will be Ω(n) C The worst case time complexity for both operations will be Ω(n) D Worst case time complexity for both operations will be Ω(logn)
Data-Structures       Queues       2016 set-01
Question 1 Explanation:
Since it is mentioned in the question that both of the operations are performed efficiently. Hence even the worst case time complexity will be O(1) by the use of the Circular queue there won't be any need of shifting in the array.
 Question 2
Suppose a circular queue of capacity (n - 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
 A full: (REAR+1)mod n == FRONT empty: REAR == FRONT B full: (REAR+1)mod n == FRONT empty: (FRONT+1) mod n == REAR C full: REAR == FRONT empty: (REAR+1) mod n == FRONT D full: (FRONT+1)mod n == REAR empty: REAR == FRONT
Data-Structures       Queues       Gate 2012
Question 2 Explanation:

To circulate within the queue we have to write mod n for (Rear + 1).
We insert elements using Rear & delete through Front.
 Question 3

 A Leaves the queue Q unchanged B Reverses the order of the elements in the queue Q C Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order D Empties the queue Q
Data-Structures       Queues       Gate 2007-IT
Question 3 Explanation:
As a recursive call, and removing from front while inserting from end, that means that element will be deleted at last and will be inserted 1st in the new queue. And like that it will continue till first call execute insert (Q, i) function. So the queue is in reverse order.
There are 3 questions to complete.