The potential method assigns a number to each state of a data structure. Let be the state after operation , , and its actual cost. Its amortized cost is the actual cost plus the change in potential. Summing and cancelling adjacent potentials gives a telescoping sum:
If and every reachable , the sum of amortized costs bounds the actual total for every prefix. A nonzero initial potential contributes the explicit additive term . Potential is proof bookkeeping; the algorithm need not store it.[ref]
For dynamic array doubling, choose
The potential method now starts at . After every nonempty reachable state, , so the maximum equals . There are just three cases for append:
  • First append: becomes , so and .
  • Later append without resizing: stays fixed and increases by one, so and .
  • Append to a full capacity : becomes , so the potential changes from to . Hence , including the resize from capacity one to two.
For every , the total charge is , and the telescoping sum proves
This agrees exactly with . The unmodified choice has initial value , so calling it nonnegative at the empty state would be incorrect. It also works if that initial constant is retained in the identity; alternatively, starts at zero and is nonnegative on these reachable states. The maximum above keeps a literal nonnegative credit balance from the beginning. The proof covers append alone; allowing reserve or arbitrary deletion changes the reachable states and requires a new argument.
Figure 1. . Each row satisfies . Before append 9 there are eight credits; its charge of three and actual cost of nine leave two. Credits pay for counted work and do not represent spare computer memory slots. Details.
In the potential method, an operation's amortized cost is . It can exceed or fall below its actual cost . The endpoint potentials determine how the total charge compares with the total actual cost.

Articles by others on the same topic (0)

There are currently no matching articles.