1. Title: implement a queue with two stacks . First with a stack input data, and then output this stack to another stack, you can form a queue of FIFO order.
Because the PHP array can emulate the implementation of the stack, the code is as follows:
2. implement a stack with two queues . The order of the stacks is mainly advanced after-out. First with a queue input data, and then each time the data to transfer the a queue of data to B queue, a queue only left the last number, and then the a queue of data out of the team is the last element. Each time the data is transferred back and forth to the queue.Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the queue and stack: two stack implementation queue, two queue implementation stack, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.