The queue data structure is to be realized by using stack. The number of…

2015

The queue data structure is to be realized by using stack. The number of stacks needed would be

Answer: B. 2 stacksImplementing a queue using stacks requires two stacks to manage FIFO behavior. One stack handles enqueue operations, while the second reverses elements for…

  1. A.

    It cannot be implemented

  2. B.

    2 stacks

  3. C.

    4 stacks

  4. D.

    1 stack

Attempted by 1263 students.

Show answer & explanation

Correct answer: B

Implementing a queue using stacks requires two stacks to manage FIFO behavior. One stack handles enqueue operations, while the second reverses elements for dequeue.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…