next up previous
Next: Up: Previous:

Accounting Method

Different operations have different costs.

Cost overestimates fund cost underestimates.



Example

Operation Cost  
bit to 1 2* overestimate
bit to 0 0** underestimate

Need to set some bits to 1 before set to 0.

* one for actual bit flip, one for credit
** use credit from the time when set to 1

Because resetting bits in the while loop are ``paid for'', each call to Increment incurs a cost of 2 for the bit set to 1.

Each call is O(1) amortized cost
n calls is O(n) amortized cost

Constraints

1.
The total amortized cost must be an upper bound on the actual cost.
2.
The total credit in data structures must always be nonnegative.


next up previous
Next: Up: Previous: