3.1.5 · D1Complexity Analysis

Foundations — Amortized analysis — aggregate, accounting, potential methods

2,300 words10 min readBack to topic

Before you can read a single line of the parent topic, you must own every symbol it throws at you. This page builds each one from nothing, in the order they depend on each other.


0. What is an "operation" and a "sequence"?

Figure — Amortized analysis — aggregate, accounting, potential methods
Figure s01 — A row of operation-boxes numbered left to right. Blue boxes are cheap (); the occasional red box is a rare expensive spike. This row is the object every symbol on this page talks about.

Why the topic needs this: amortized analysis is a claim about a whole row of boxes, not about one box. Every symbol below is a way of talking about that row.


1. Actual cost


2. Summation and total cost

Why the topic needs it: the honest average is . Everything downstream is a trick to compute or bound without summing every spike by brute force.


3. Amortized cost and the reported amortized cost


4. Asymptotic notation: and

Figure — Amortized analysis — aggregate, accounting, potential methods
Figure s02 — Two cost curves against structure size . The red diagonal is — the size of one worst-case push. The flat blue line is — the amortized cost we aim to prove. The whole topic is the arrow from red down to blue.


5. The data-structure state and capacity , size

Figure — Amortized analysis — aggregate, accounting, potential methods
Figure s03 — A shelf of allocated slots (orange width) of which currently hold a book (blue width). When the blue width reaches the orange width the array is full and must double.


6. Geometric series — why doublings stay cheap

Figure — Amortized analysis — aggregate, accounting, potential methods
Figure s04 — Doubling blocks of width laid end to end. The full stack () is barely wider than the final block (): the sum is under twice the last term, which is why total copy work stays below .

Why the topic needs it: this single inequality is why the aggregate method gives , hence amortized.


7. The potential function and


8. The three method names (preview)

The parent topic solves everything three different ways. You do not need the details yet — just recognise the names when the map below uses them:

These same symbols power the harder examples the parent links: credits-on-bits for the Disjoint Set Union (Union-Find) and rank arguments, potential for Splay Trees and Fibonacci Heaps. Master them here once.


Prerequisite map

The diagram below shows how the foundations feed into the three methods and finally into the topic.

operation and sequence, m

actual cost c_i

summation and total T of m

amortized cost c-hat

Big-O and Big-Omega

dynamic array n and s

geometric series

aggregate method

accounting method credits

potential Phi and delta Phi

potential method

Amortized analysis

Recall Plaintext walkthrough of the map (read this if the diagram does not render)

Start at "operation and sequence, " — the raw idea of a row of boxes. That feeds "actual cost ", which feeds "summation and total ", which (together with "Big-O") feeds the central node "amortized cost ". From three arrows fan out to the three methods: aggregate (also fed by "dynamic array " → "geometric series"), accounting (credits), and potential (fed by " and "). All three methods point into the final node, Amortized analysis — the parent topic. In short: symbols → → three methods → the topic.


Equipment checklist

Test yourself — each line is a question ::: answer reveal.

What does the index in tell you?
Which operation in the sequence we mean — the -th box in the left-to-right row.
Read in plain English.
Add up the actual cost of every operation from the first () to the last ().
What is ?
The total actual cost of the whole sequence, — one number.
What does the hat in signify?
A cost we choose to charge for one operation, which may differ from the real ; only rule is .
Difference between and (no index)?
is the charge on one operation; is the single averaged number we report.
Why may we report the single average ?
Because , dividing by gives — a guaranteed ceiling on true average cost.
vs in shape?
is a flat horizontal line (bounded constant); is a rising diagonal (grows with size).
For a dynamic array, what are and ?
= elements currently stored; = allocated capacity; always , full when .
Value of , and why it matters?
, which is twice the last term — so copy work stays under .
What is and its two required conditions?
Stored energy of state ; need and for all .
What does equal?
, the change in potential during operation .
State the master equation of the potential method.
— actual cost plus change in potential.
Name the three methods in one word each.
Aggregate (add-and-divide), Accounting (bank credit), Potential (stored energy ).