Algorithm 3 Queue Implemented using Two Stacks
Require: and are two stacks.
Ensure: Implementation of queue operations with and .
1:procedure Enqueue()
2:Push()
3:end procedure
4:
5:procedure Dequeue()
6:if StackEmpty() then
7:while not StackEmpty() do
8: Pop()
9:Push()
10:end while
11:end if
12:return Pop()
13:end procedure