1
GATE CSE 2026 Set 2
MCQ (More than One Correct Answer)
+2
-0

Consider a stack $S$ and a queue $Q$. Both of them are initially empty and have the capacity to store ten elements each. The elements $1,2,3,4$, and 5 arrive one by one, in that order. When an element arrives, it is assigned either to $S$ (pushed on $S$ ) or to $Q$ (enqueued to $Q)$. 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 $Q$ is emptied by dequeueing all elements. The output obtained by following this process is 43125 .

Given the output, the objective is to predict whether an element was assigned to $S$ or $Q$. Which of the following options is/are possible valid assignment(s) of the elements?

Note: In the options, the notation $x S$ denotes that element $x$ was assigned to $S$ and $y Q$ denotes that element $y$ was assigned to $Q$.

A

$1 S, 2 Q, 3 S, 4 S, 5 Q$

B

$1 Q, 2 Q, 3 S, 4 S, 5 Q$

C

$1 Q, 2 Q, 3 Q, 4 S, 5 S$

D

$1 S, 2 S, 3 S, 4 Q, 5 Q$

2
GATE CSE 2025 Set 2
MCQ (More than One Correct Answer)
+2
-0.67

Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct. We wish to augment the stack data structure with an $\mathrm{O}(1)$ time MIN operation that returns a pointer to the record with smallest key present in the stack

1. without deleting the corresponding record, and

2. without increasing the complexities of the standard stack operations.

Which one or more of the following approach(es) can achieve it?

A
Keep with every record in the stack, a pointer to the record with the smallest key below it.
B
Keep a pointer to the record with the smallest key in the stack.
C
Keep an auxiliary array in which the key values of the records in the stack are maintained in sorted order.
D
Keep a Min-Heap in which the key values of the records in the stack are maintained.
3
GATE CSE 2024 Set 2
MCQ (More than One Correct Answer)
+2
-0

Let S1 and S2 be two stacks. S1 has capacity of 4 elements. S2 has capacity of 2 elements. S1 already has 4 elements: 100, 200, 300, and 400, whereas S2 is empty, as shown below.

Stack S1
400 (Top)
300
200
100
Stack S2

Only the following three operations are available:

PushToS2: Pop the top element from S1 and push it on S2.
PushToS1: Pop the top element from S2 and push it on S1.
GenerateOutput: Pop the top element from S1 and output it to the user.

Note that the pop operation is not allowed on an empty stack and the push operation is not allowed on a full stack.

Which of the following output sequences can be generated by using the above operations?

A

100, 200, 400, 300

B

200, 300, 400, 100

C

400, 200, 100, 300

D

300, 200, 400, 100

4
GATE CSE 2023
Numerical
+2
-0

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

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 ____________.

Your input ____

GATE CSE Subjects

Browse all chapters by subject

Software Engineering
Web Technologies