Stack using two queues

Write a code how to implement stack using two queues?
and vice versa ?

Showing Answers 1 - 2 of 2 Answers

ilushka

  • Nov 3rd, 2011
 

Something like this:

Code
  1. span style="font-style: italic;">// At any given time one queue will be empty// curr - queue with all the elementsm

  2.   // next - empty queue that will get n-1 elemets// "Copy" all the elements except last

ptmich

  • May 28th, 2012
 

Code
  1. span style="font-style: italic;">// At any given time one queue will be empty// curr - queue with all the elements

  2. 13.  // next - empty queue that will get n-1 elemets// "Copy" all the elements except last


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions