Queue: GATE CS Previous Year Questions

Queue · Data Structures

14 questions · asked in 13 of 27 years (2000–2026)

MCQ 9 · MSQ 1 · NAT 41-mark 7 · 2-mark 7

2000Questions per year2026

Questions 1–5 of 14

Q1GATE 2026 (Session 2)2 marksMSQ
Consider a stack SS and a queue QQ. Both of them are initially empty and have the capacity to store ten elements each. The elements 1,2,3,41,2,3,4, and 55 arrive one by one, in that order. When an element arrives, it is assigned either to SS (pushed on SS ) or to QQ (enqueued to QQ ). Once all the five elements are stored, the output is generated in two steps. First, stack S is emptied by popping all elements. Then queue QQ is emptied by dequeueing all elements. The output obtained by following this process is 4 3 1 2 5\text{4 3 1 2 5}.

Given the output, the objective is to predict whether an element was assigned to SS or QQ.

Which of the following options is/are possible valid assignment(s) of the elements?
Note: In the options, the notation xSx S denotes that element xx was assigned to SS and yQy Q denotes that element yy was assigned to QQ.

One or more options are correct.

Q2GATE 20232 marksNAT
Consider a sequence aa of elements a0=1,a1=5,a2=7,a3=8,a4=9,  and  a5=2a_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 SS and a queue QQ, both of which are initially empty.

I: push the elements of a from a0a_0 to a5a_5 in that order into SS.
II: enqueue the elements of a from a0a_0 to a5a_5 in that order into QQ.
III: pop an element from SS.
IV: dequeue an element from QQ.
V: pop an element from SS.
VI: dequeue an element from QQ.
VII: dequeue an element from QQ and push the same element into SS.
VIII: Repeat operation VII three times.
IX: pop an element from SS.
X: pop an element from SS.

The top element of SS after executing the above operations is ___.

Q3GATE 20222 marksNAT
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)Enqueue(Q,element) and Dequeue(Q)Dequeue(Q). The minimum number of EnqueueEnqueue 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
Initial State Final State Head Head Q1 Q2 Q1 Q2 Head Head 1234 4321

Q4GATE 2021 (Session 1)1 markNAT
Consider the following sequence of operations on an empty stack.

push(54); push(52); pop(); push(55); push(62); s=pop();

Consider the following sequence of operations on an empty queue.

enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q=dequeue();

The value of s+q is ___________.

Q5GATE 20181 markMCQ−0.33 if wrong
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.
headtail
Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?

Keep practising

Topics in Data Structures

All CS topics ›