August 31

Amortized Cost

Today I continued with the analysis of ArrayStacks, in particular Lemma 2..1. here is an alternate presentation of amortized analysis.

We use Lemma 2..1 as follows. The goal of analyzing running time is to estimate the execution of the entire program, say a program which used ArrayStacks. When doing that, we will have to add up the cost of all the calls to the ArrayStack operations over the whole program. The difficulty is that when doing so, we would have to be very careful about adding the cost of add and remove since they differ depending on the size. So instead, we take the following approach:

The result is the following statement:

In a program which makes calls to an ArrayStack, adding up the actual cost of all data structure
operations is equal to adding up all the stated amortized costs for all operations.

The reason for the above statement is that we "paid" computation to create a coin and later spent it so in the total sum over all operations, we get the same result. The point of doing this is that it is easier to add up the amortized costs, since the amortized cost of add and remove is always \(O(n-i)\).

Exercises