資料結構›Ch3 堆疊與佇列
第 13 題/共 28 題
◀ DS 13/28
13. Stack、Queue、Amortized Analysis
#DS-03-013易StackQueueAmortized Analysis
  1. Stack operations are
  • Push(item): S.push(item) pushes item into the stack S.
  • Pop(): S.Pop() removes top of the stack S.
  • isEmpty(): S.isEmpty() answers whether the stack S is empty.

The questions are about implementing a FIFO queue Q by using two stacks S1 and S2.

(a) (2%). Describe the algorithm enQueue(item) (insert item into Q) using pseudo code.

(b) (2%). Describe the algorithm deQueue() (delete an item from the Q) using pseudo code.

(c) (4%). Show that deQueue takes O(1) amortized cost.

📄 交大112
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch3 堆疊與佇列
本章題號 · 1–20 / 28