The accounting method is one of the main methods used in amortised analysis of algorithms. The core principle is simple:

  • For an operation and a sequence of inputs .
  • Let be the actual cost of and be the amortised cost for .
  • Then, for each input, we assign a credit, where is the leftover credit after executing operation . We require that .
    • If , i.e., the amortised cost is more, we can execute the operation. Then, we store the difference as “credit” to be used for later operations.
    • If , the actual cost is more. In this case, we use the credit that we’ve built up to execute the operation. Even if the difference , we can still use the credit to ensure the summation is non-negative.
      • If the summation is non-negative, then the guess for is wrong.
    • Note: if something costs \mathcal O(1)\mathcal O(0)k\mathcal O(k)$.

Another aspect of our proof is the credit invariant. We make a claim about the value of the cumulative stored credit . Usually it looks something like “element with property contains stored credit ( can be dependent on property )“.

Then, if we show that the credit invariant always maintains positive stored credit, i.e., for all , then each operation is amortised.

Note that we don’t need to exactly reach 0 at the end of the day (when the structure is empty or something). We can charge more than we need, and use less credit than we have. This maintains the invariant without ever reaching 0.