Overview

Amortized analysis determines the average cost per operation over a worst-case sequence of operations on a data structure, without using probability. Even though a single operation may occasionally be expensive, amortized analysis shows that the average cost across all operations is small. The chapter presents three techniques — aggregate analysis, the accounting method, and the potential method — applying each to stack operations with MULTIPOP and binary counter INCREMENT. It culminates with a detailed analysis of dynamic tables that expand and contract, proving O(1) amortized cost per insertion and deletion.

Key Concepts

Algorithms and Techniques

1. Stack with MULTIPOP — All Three Methods

Setup: A stack supports PUSH (cost 1), POP (cost 1), and MULTIPOP(S, k) (pops min(k, s) items, cost = min(k, s), where s is stack size).

Aggregate analysis:

Accounting method: