# Queue

 Question 1
Consider a sequence $a$ of elements $a_0 = 1, a_1 = 5, a_2 = 7, a_3 = 8, a_4 = 9, \; and \; a_5 = 2$. The following operations are performed on a stack $S$ and a queue $Q$, both of which are initially empty.

I: push the elements of a from $a_0$ to $a_5$ in that order into $S$.
II: enqueue the elements of a from $a_0$ to $a_5$ in that order into $Q$.
III: pop an element from $S$.
IV: dequeue an element from $Q$.
V: pop an element from $S$.
VI: dequeue an element from $Q$.
VII: dequeue an element from $Q$ and push the same element into $S$.
VIII: Repeat operation VII three times.
IX: pop an element from $S$.
X: pop an element from $S$.

The top element of $S$ after executing the above operations is ___.
 A 7 B 8 C 9 D 2
GATE CSE 2023   Data Structure
Question 1 Explanation:
 Question 2
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations allowed on these two queues are $Enqueue(Q,element)$ and $Dequeue(Q)$. The minimum number of $Enqueue$ operations on Q1 required to place the elements of Q1 in Q2 in reverse order (shown as the Final State in the figure) without using any additional storage is A 4 B 2 C 0 D 1
GATE CSE 2022   Data Structure
Question 2 Explanation:

 Question 3
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 3 Explanation:
 Question 4
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 4 Explanation:
 Question 5
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 5 Explanation:

There are 5 questions to complete.

### 3 thoughts on “Queue”

1. Ques – 7; option A will be correct, not D. Kindly check.

• 2. 