Amortized Time

From Notes
Jump to navigation Jump to search

An average time for performing an operation.

Amortized time=operations or time for num. elementsnum. elements

Plotting

Suppose that t(n) is the time recorded for an input size of n elements. The amortized cost per operation would be t(n)n. If we plot this on a graph using n as the x-coordinate and t(n)n as the y-coordinate, we can see how time relates to input size.

Amortized time can also be considered a way to determine the coefficients for a known behavior. For example, if we know that a function runs in O(nlogn) time, we can estimate the coefficient with the following fraction: t(n)nlogn.

Common Plot Types

See Asymptotic Analysis for information on Big-O notation.

  • Constant: O(1)
  • Linear: O(n)
  • Logarithmic: O(logn)
  • Quadratic: O(n2)
  • Exponential: O(kn)