0% found this document useful (0 votes)
93 views2 pages

Amortized Analysis

Amortized analysis is a method for analyzing an algorithm's time or memory complexity by looking at the average cost per operation over many operations, rather than just the worst-case cost of a single operation. It is useful when some operations are very slow but most are fast. There are three techniques used in amortized analysis: aggregate analysis, which shows the total cost of n operations is T(n); accounting method, which assigns differing charges and credits to operations; and potential method, which represents prepaid work as potential energy associated with the data structure.

Uploaded by

amisha yelpale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views2 pages

Amortized Analysis

Amortized analysis is a method for analyzing an algorithm's time or memory complexity by looking at the average cost per operation over many operations, rather than just the worst-case cost of a single operation. It is useful when some operations are very slow but most are fast. There are three techniques used in amortized analysis: aggregate analysis, which shows the total cost of n operations is T(n); accounting method, which assigns differing charges and credits to operations; and potential method, which represents prepaid work as potential energy associated with the data structure.

Uploaded by

amisha yelpale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Amortized analysis:

In computer science, amortized analysis is a method for analyzing a given


algorithm's complexity, or how much of a resource, especially time or memory,
it takes to execute. The motivation for amortized analysis is that looking at the
worst-case run time per operation, rather than per algorithm, can be too
pessimistic.

It is used for algorithms where an occasional operation is very slow, but most of
the other operations are faster. In Amortized Analysis, we analyze a sequence
of operations and guarantee a worst case average time which is lower than the
worst case time of a particular expensive operation.

Amortized analysis vs Average case analysis

Amortized analysis differs from average case analysis. Amortized analysis


doesn’t use probability where as average case analysis uses it. Amortized
analysis guarantees the average case performance of each operation in the
worst.

There are 3 techniques used in amortised analysis:

1.Aggragate analysis:

In the aggregate method of amortized analysis, we show that for all n, a


sequence of n operations takes worst-case time T(n) in total. In the worst case,
the average cost, or amortized cost, per operation is therefore T(n) / n. Note
that this amortized cost applies to each operation, even when there are
several types of operations in the sequence. The other two methods the
accounting method and the potential method, may assign different amortized
costs to different types of operations.

2.Accounting method:

In the accounting method of amortized analysis, we assign differing charges to


different operations, with some operations charged more or less than they
actually cost. The amount we charge an operation is called its amortized cost.
When an operation's amortized cost exceeds its actual cost, the difference is
assigned to specific objects in the data structure as credit. Credit can be used
later on to help pay for operations whose amortized cost is less than their
actual cost. Thus, one can view the amortized cost of an operation as being
split between its actual cost and credit that is either deposited or used up. This
is very different from the aggregate method, in which all operations have the
same amortized cost.
Often, choosing the correct parameters for the accounting method requires as
much knowledge of the problem and the complexity bounds one is attempting
to prove as the other two methods.
The accounting method is most naturally suited for proving an O(1) bound on
time.

3. Potential method
The potential method is a method used to analyze the amortized time and
space complexity of a data structure, a measure of its performance over
sequences of operations that smooth out the cost of infrequent but expensive
operations.
Instead of representing prepaid work as credit stored with specific objects in
the data structure, the potential method of amortized analysis represents the
prepaid work as "potential energy,"or just "potential," that can be released to
pay for future operations. The potential is associated with the data structure as
a whole rather than with specific objects within the data structure.

You might also like