COS 226 Exercises on Stacks and Queues
A letter means enqueue and an asterisk means dequeue in the sequence
E A S * Y * Q U E * * * S T * * * I O * N * * *
Give the sequence of values returned by the dequeue operations when this
sequence of operations is performed on an initially empty FIFO queue.
Describe how to implement a queue using two stacks.
Starting from an initially empty queue,
any sequence N of enqueue and dequeue operations
should take time proportional to N.