摘要:
10.1-7 说明如何用两个队列来实现一个栈,并分析有关栈操作的运行时间。QUEUE A,BPUSH(S,x)if A正在使用 if tail[A]+1=head[A] error "upflow" else ENQUEUE(A,x)else if tail[B]+1=head[B] error "upflow" else ENQUEUE(B,x)POP(S)if A正在使用 if QUEUE_EMPTY(A) error "underflow" else while head[A]+1!=tail[A] ENQUEUE(B,DEQU
阅读全文