GATE CSE
First time here? Checkout the FAQ!
x
+5 votes
1.1k views

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
asked in DS by Veteran (92.5k points) 964 2327 3113 | 1.1k views

2 Answers

+3 votes
Best answer

The correct option is B.

answered by Active (2.3k points) 1 15 39
selected by
@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.
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.
it will work for all the cases.
+5 votes
answered by Veteran (50.4k points) 22 90 410
Answer:

Related questions

+4 votes
2 answers
2
asked in DS by SSrawat (81 points) 3 | 31 views
0 votes
0 answers
3
asked in DS by moin (311 points) 5 14 | 69 views


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23338 Points

  2. Bikram

    17048 Points

  3. Habibkhan

    7912 Points

  4. srestha

    6228 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4968 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4286 Points

  9. sushmita

    3964 Points

  10. Rishi yadav

    3794 Points


Recent Badges

Popular Question makhdoom ghaya
Popular Question junaid ahmad
Notable Question learner_geek
Notable Question jothee
Popular Question jothee
Notable Question Jeffrey Jose
Notable Question air1ankit
Nice Question jothee
Verified Human shaleen25
Popular Question jothee
27,290 questions
35,142 answers
83,920 comments
33,231 users