Aggregate and Accounting Amortized Analysis

Bound a sequence of stack operations by counting how often costly work can happen, then interpret the bound as stored credit.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Count successful removals over the sequence
  2. Assign the same reasoning to individual operations

Count successful removals over the sequence

A multipop removes up to \(k\) stack items, stopping at an empty stack. One call can cost proportional to the stack size. Starting empty, however, each removed item was previously pushed and can be removed only once. In a sequence of \(m\) calls that includes \(p\) pushes, at most \(p\) item removals occur. With constant per-call overhead, the cost is at most \(O(m+p)=O(m)\). The argument holds for adversarially chosen sequences.

Assign the same reasoning to individual operations

Charge two item operations to each push under the unit-work model. Spend one immediately and attach one credit to the pushed item. A pop or multipop spends a credit for each item it removes. Credits never go negative and unused credits may remain at the end. This accounting view is closely related to the potential method, where total stored credit is the potential. A longest-prefix maximum or real-time constraint concerns individual stalls, as explained by amortized versus per-operation latency.[1]

References

  1. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩