On Aug 1, 7:22 am, ravi <dceravigu...@gmail.comwrote:
Can any body tell me
How to implement a stack using two queues
Thax in advance
Hi ,
I am just giving you hint for its possible algo.
1. Use one queue to push data into...say Q-a.Make a common push() and
pop() common function passing front and rear initially NULL.
2. For pop operation,
if (Q-a.front!=Q-a.rear)
{
pop and add to Q-b;
}
else
{
pop(); //this is our output
Q-a.front=Q-b.front
Q-a.rear=Q-b.rear;
Q-b.front=Q-b.rear=NULL
}
Hope this helps.
~Col