in DS
4,417 views
9 votes
9 votes

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

  1. It cannot be implemented
  2. 2 stacks
  3. 4 stacks
  4. 1 stack
in DS
4.4k views

2 Answers

9 votes
9 votes
Best answer

The correct option is B.

selected by

4 Comments

@pankaj kumaras you have written if we want to perform queue operation then we need to pop ...but actually for queuing you don't need to pop you just need to push the elements in stack A like push a then push b push c this is for queuing but for dequeuing you must pop them from stack A and push them into B now for dequeuing pop then one by one to maintain the queue order.
1
1
you are right but the case is after insertion some element we want to remove an element from the queue and then again we want insertion that's why i did this.
0
0
it will work for all the cases.
0
0
Here if asked that for enqueue purpose how many stacks will be required? Then answer will be 1 right?
0
0
6 votes
6 votes
by
Answer:

Related questions