Why it matters

Aggregate method is simplest. Understanding shapes analysis.

Advertisement

The architecture

Bound worst-case total for n ops.

Divide by n = amortized per op.

All ops same amortized cost.

Aggregate methodWorst-case totalfor n opsDivide by namortized costAll ops sameamortized costSimple but coarser; accounting + potential give per-op flexibility
Aggregate method.
Advertisement

How it works end to end

Simple + coarse.

All ops same amortized cost.

Stack of k pushes + one costly pop_all.