Problem: Show how to implement a queue using two stacks S1 and S2 so that the amortized cost of each operation on the queue is O(1).
Question 1. Give the pseudocode for the Enqueue(x) operation and the Dequeue() operation
(you can omit error checking for under?ow and over?ow of the stacks).
Question 2. Use the accounting method to charge each operation a constant amortized cost and prove that a sequence of n Enqueue and Dequeue cost O(n) time overall.
Can anyone provide the answer for given problem?