Amortized Analysis of A Binary Counter: Andreas Klappenecker
Amortized Analysis of A Binary Counter: Andreas Klappenecker
Counter
Andreas Klappenecker
Binary Counter
•
Aggregate Method
The worst case running time occurs when all k bits are flipped, so
increment(A) has running time O(k).
21
Accounting Method for k-Bit
1
0 0 0 0 0 0 0 1 0 0
1 1 1
0 0 0 0 1 0 0 1 0 1
1 1 1
0 0 0 1 0 0 0 1 1 0
1 1 1 1 1
0 0 0 1 1 0 0 1 1 1
Accounting Method
All changes from 1 to 0 are paid for with previously stored credit
(never go into red)
Actual cost: ci = ti + 1
- if Bi = 0, then Bi-1 = ti = k
Difference in Potentials: