GATE 2014 CS (CS2) – Question 51
A stack supports REVERSE (reverses all elements) in addition to PUSH and POP. Which is TRUE?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) A queue can have three-instruction ENQUEUE and one-instruction DEQUEUE.
Explanation
Keep the oldest queued item at the stack top. To enqueue, reverse the stack, push the new item, then reverse again, restoring older items ahead of it. Dequeue is a single pop. Thus **C**, three instructions for enqueue and one for dequeue, preserves FIFO order after every operation.