GATE 2021 CS – Question 31
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 ______.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 86
Explanation
Stack: pop returns 52, then after pushing 55 and 62, s = 62. Queue: first dequeue removes 21, and q = 24. s + q = 86.