GATE CS 2021 Set 1 | Question 31
Programming & Data Structures › Stacks & Queues · NAT · 1 mark · Answer: 86
- Question 31Programming & Data Structuresnat1 markConsider the following sequence of operations on an empty stack.
Consider the following sequence of operations on an empty queue.push(54); push(52); pop(); push(55); push(62); s = pop();
The value of is ______.enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q = dequeue();Answer: 86
Solution
Stack: after the operations the top popped into is 62. Queue (FIFO): the second dequeue returns 24, so . Hence .
More GATE PYQ on Stacks & Queues
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2021 Set 1 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →