Unformatted text preview: »Initial data structure D0 starts with zero credits.
Key invariant. The total number of credits in the data structure â‰¥ 0.
n
n
ci
Ë†
i=1 ci 0 i=1 Theorem. Starting from the initial data structure D0, the total actual cost of
n n i=1 i=1 any sequence of n operations is at most the sum of the amortized ci . â–ª
costs.
ci
Ë†
Pf. The amortized cost of the sequence of operations is: Intuition. Measure running time in terms of credits (time = money). 17 Binary counter: accounting method
Credits. One credit pays for a bit flip.
Invariant. Each bit that is set to 1 has one credit.
Accounting. ãƒ»Flip bit j from 0 to 1: charge two credits (use one and save one in bit j).
increment
7 6 5 4 3 2 1 0 0 1 0 0 1 1 1 1
0 18 Binary counter: accounting method
Credits. One credit pays for a bit flip.
Invariant. Each bit that is set to 1 has one credit.
Accounting. ãƒ»Flip bit j from 0 to 1: charge two credits (use one and save one in bit j).
ãƒ»Flip bit j from 1 to 0: pay for it with saved credit in bit j.
in...
View
Full Document
 Spring '14
 Analysis of algorithms, DI, Amortized analysis, Potential method

Click to edit the document details