Lably
Skip to content

Potential method

  • 6 min read
  • 5 chapters

Related on Lably

Through Data structure, Potential energy and Big O notation

Definition of amortized time

In the potential method, a function Φ is chosen that maps states of the data structure to non-negative numbers. If S is a state of the data structure, Φ(S) represents work that has been accounted for ("paid for") in the amortized analysis but not yet performed. Thus, Φ(S) may be thought of as calculating the amount of potential energy stored in that state. The potential value prior to the operation of initializing a data structure is defined to be zero. Alternatively, Φ(S) may be thought of as representing the amount of disorder in state S or its distance from an ideal state.

Let o be any individual operation within a sequence of operations on some data structure, with Sbefore denoting the state of the data structure prior to operation o and Safter denoting its state after operation o has completed. Once Φ has been chosen, the amortized time for operation o is defined to be

Tamortized(o)=Tactual(o)+C⋅(Φ(Safter)−Φ(Sbefore)),

where C is a non-negative constant of proportionality (in units of time) that must remain fixed throughout the analysis. That is, the amortized time is defined to be the actual time taken by the operation plus C times the difference in potential caused by the operation.

When studying asymptotic computational complexity using big O notation, constant factors are irrelevant and so the constant C is usually omitted.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Computing and communication