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 stacks — Implementing a queue using stacks requires two stacks to manage FIFO behavior. One stack handles enqueue operations, while the second reverses elements for…
- A.
It cannot be implemented
- B.
2 stacks
- C.
4 stacks
- 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…