1) Take two stacks S1 and S2

For insertion operation:
   1)  push into S1  and  if S2 is empty push  into S2 and S2 is not empty
pop all elements and push new element into S2 then push poped all elements
(S2 contains all elements of S1 in  reverse order)

For deletion:

Delete from S2





----------------------------------------
CHERUVU JAANU REDDY
M.Tech in CSIS


On Sun, Feb 7, 2010 at 7:02 PM, naren <[email protected]> wrote:

> how to Implement a Queue using a stack if space complexity is there...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to