Queue

Question 1
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.

Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
A
\Theta (1), \Theta (1)
B
\Theta (1), \Theta (n)
C
\Theta (n), \Theta (1)
D
\Theta (n), \Theta (n)
GATE CSE 2018   Data Structure
Question 2
Which of the following data structure is useful in traversing a given graph by breadth first search?
A
Stack
B
Queue
C
List
D
None of the above
ISRO CSE 2017   Data Structure
Question 3
A circular queue has been implemented using a single linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so that insertion and deletion operation can be performed in O (1) time ?

I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
A
I only
B
II only
C
Both I and II
D
Neither I nor II
GATE CSE 2017 SET-2   Data Structure
Question 4
Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.

The maximum possible number of iterations of the while loop in the algorithm is_________.
A
16
B
64
C
256
D
1027
GATE CSE 2016 SET-1   Data Structure
Question 5
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. 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 \Omega(n)
C
The worst case time complexity for both operations will be \Omega(n)
D
Worst case time complexity for both operations will be \Omega(logn)
GATE CSE 2016 SET-1   Data Structure
Question 6
The queue data structure is to be realized by using stack. The number of stacks needed would be
A
It cannot be implemented
B
2 stacks
C
4 stacks
D
1 stack
ISRO CSE 2015   Data Structure
Question 7
Consider a standard Circular Queue implementation (which has the same condition for Queue Full and Queue Empty) whose size is 11 and the elements of the queue are q[0],q[1],... q[10].
The front and rear pointers are initialized to point at q[2]. In which position will the ninth element be added?
A
q[0]
B
q[1]
C
q[9]
D
q[10]
ISRO CSE 2014   Data Structure
Question 8
Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.
 MultiDequeue(Q){
m = k
while (Q is not empty) and (m > 0) {
   Dequeue(Q)
   m = m - 1
   }
} 
What is the worst case time complexity of a sequence of n queue operations on an initially empty queue?
A
\Theta (n)
B
\Theta (n+k)
C
\Theta (nk)
D
\Theta (n^{2})
GATE CSE 2013   Data Structure
Question 9
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
GATE CSE 2012   Data Structure
Question 10
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:
i. isEmpty(Q) returns true if the queue is empty, false otherwise.
ii. delete(Q) deletes the element at the front of the queue and returns its value.
iii. insert(Q,i) inserts the integer i at the rear of the queue.
Consider the following function
void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
   i = delete(Q);
   f(Q);
   insert(Q, i);
  }
} 

What operation is performed by the above function f ?
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
GATE IT 2007   Data Structure
There are 10 questions to complete.

3 thoughts on “Queue”

Leave a Comment

Like this FREE website? Please share it among all your friends and join the campaign of FREE Education to ALL.