Microsoft
Company
Programming
Technical
What is the minimum no of stack of size n is needed to make a queue of size n?
1 or 2 or 3 or 4
Read Solution (Total 5)
-
- 2 coz for any number of elements...minimum number of stack required is 2. ex: 1,2,3,4...if u insert these nos in stack...1 wil be at the bottom of stack and 4 wil be at top of the stack. Take a second stack ..n pop elements from first stack till second element tht is 2. Remaining element in first stack is 1. put in a queue . den from second stack pop elements n go on putting in queue. den u get the required queue
- 9 years agoHelpfull: Yes(3) No(1)
- 2 is enough to make a stack, one for insert one for remove
- 10 years agoHelpfull: Yes(2) No(1)
- 2 stacks of size is needed
- 6 years agoHelpfull: Yes(0) No(0)
- Minimun no of stack of size n is needed to make q queue of size n is 2, 1 for push a stack and another 1 is pop the stack.
- 3 years agoHelpfull: Yes(0) No(0)
- 2 is the minimum number of stack needed to make a queue , one for push and one for pop.
- 1 year agoHelpfull: Yes(0) No(0)
Microsoft Other Question