<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
amortized	B-General_Concept
analysis	I-General_Concept
is	O
a	O
method	O
for	O
analyzing	B-General_Concept
a	O
given	O
algorithm	O
's	O
complexity	O
,	O
or	O
how	O
much	O
of	O
a	O
resource	O
,	O
especially	O
time	O
or	O
memory	O
,	O
it	O
takes	O
to	O
execute	B-General_Concept
.	O
</s>
<s>
The	O
motivation	O
for	O
amortized	B-General_Concept
analysis	I-General_Concept
is	O
that	O
looking	O
at	O
the	O
worst-case	B-General_Concept
run	O
time	O
can	O
be	O
too	O
pessimistic	O
.	O
</s>
<s>
Instead	O
,	O
amortized	B-General_Concept
analysis	I-General_Concept
averages	O
the	O
running	O
times	O
of	O
operations	O
in	O
a	O
sequence	O
over	O
that	O
sequence	O
.	O
</s>
<s>
As	O
a	O
conclusion	O
:	O
"	O
Amortized	B-General_Concept
analysis	I-General_Concept
is	O
a	O
useful	O
tool	O
that	O
complements	O
other	O
techniques	O
such	O
as	O
worst-case	B-General_Concept
and	O
average-case	O
analysis.	O
"	O
</s>
<s>
For	O
a	O
given	O
operation	O
of	O
an	O
algorithm	O
,	O
certain	O
situations	O
(	O
e.g.	O
,	O
input	O
parametrizations	O
or	O
data	B-General_Concept
structure	I-General_Concept
contents	O
)	O
may	O
imply	O
a	O
significant	O
cost	O
in	O
resources	O
,	O
whereas	O
other	O
situations	O
may	O
not	O
be	O
as	O
costly	O
.	O
</s>
<s>
The	O
amortized	B-General_Concept
analysis	I-General_Concept
considers	O
both	O
the	O
costly	O
and	O
less	O
costly	O
operations	O
together	O
over	O
the	O
whole	O
sequence	O
of	O
operations	O
.	O
</s>
<s>
Amortized	B-General_Concept
analysis	I-General_Concept
initially	O
emerged	O
from	O
a	O
method	O
called	O
aggregate	B-General_Concept
analysis	I-General_Concept
,	O
which	O
is	O
now	O
subsumed	O
by	O
amortized	B-General_Concept
analysis	I-General_Concept
.	O
</s>
<s>
The	O
technique	O
was	O
first	O
formally	O
introduced	O
by	O
Robert	O
Tarjan	O
in	O
his	O
1985	O
paper	O
Amortized	B-General_Concept
Computational	O
Complexity	O
,	O
which	O
addressed	O
the	O
need	O
for	O
a	O
more	O
useful	O
form	O
of	O
analysis	O
than	O
the	O
common	O
probabilistic	O
methods	O
used	O
.	O
</s>
<s>
Amortization	B-General_Concept
was	O
initially	O
used	O
for	O
very	O
specific	O
types	O
of	O
algorithms	O
,	O
particularly	O
those	O
involving	O
binary	O
trees	O
and	O
union	O
operations	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
now	O
ubiquitous	O
and	O
comes	O
into	O
play	O
when	O
analyzing	B-General_Concept
many	O
other	O
algorithms	O
as	O
well	O
.	O
</s>
<s>
Amortized	B-General_Concept
analysis	I-General_Concept
requires	O
knowledge	O
of	O
which	O
series	O
of	O
operations	O
are	O
possible	O
.	O
</s>
<s>
This	O
is	O
most	O
commonly	O
the	O
case	O
with	O
data	B-General_Concept
structures	I-General_Concept
,	O
which	O
have	O
state	B-Application
that	O
persists	O
between	O
operations	O
.	O
</s>
<s>
The	O
basic	O
idea	O
is	O
that	O
a	O
worst-case	B-General_Concept
operation	O
can	O
alter	O
the	O
state	B-Application
in	O
such	O
a	O
way	O
that	O
the	O
worst	O
case	O
cannot	O
occur	O
again	O
for	O
a	O
long	O
time	O
,	O
thus	O
"	O
amortizing	O
"	O
its	O
cost	O
.	O
</s>
<s>
There	O
are	O
generally	O
three	O
methods	O
for	O
performing	O
amortized	B-General_Concept
analysis	I-General_Concept
:	O
the	O
aggregate	O
method	O
,	O
the	O
accounting	B-General_Concept
method	I-General_Concept
,	O
and	O
the	O
potential	B-General_Concept
method	I-General_Concept
.	O
</s>
<s>
Aggregate	B-General_Concept
analysis	I-General_Concept
determines	O
the	O
upper	O
bound	O
T(n )	O
on	O
the	O
total	O
cost	O
of	O
a	O
sequence	O
of	O
n	O
operations	O
,	O
then	O
calculates	O
the	O
amortized	B-General_Concept
cost	O
to	O
be	O
T(n )	O
/	O
n	O
.	O
</s>
<s>
The	O
accounting	B-General_Concept
method	I-General_Concept
is	O
a	O
form	O
of	O
aggregate	B-General_Concept
analysis	I-General_Concept
which	O
assigns	O
to	O
each	O
operation	O
an	O
amortized	B-General_Concept
cost	O
which	O
may	O
differ	O
from	O
its	O
actual	O
cost	O
.	O
</s>
<s>
Early	O
operations	O
have	O
an	O
amortized	B-General_Concept
cost	O
higher	O
than	O
their	O
actual	O
cost	O
,	O
which	O
accumulates	O
a	O
saved	O
"	O
credit	O
"	O
that	O
pays	O
for	O
later	O
operations	O
having	O
an	O
amortized	B-General_Concept
cost	O
lower	O
than	O
their	O
actual	O
cost	O
.	O
</s>
<s>
Because	O
the	O
credit	O
begins	O
at	O
zero	O
,	O
the	O
actual	O
cost	O
of	O
a	O
sequence	O
of	O
operations	O
equals	O
the	O
amortized	B-General_Concept
cost	O
minus	O
the	O
accumulated	O
credit	O
.	O
</s>
<s>
Because	O
the	O
credit	O
is	O
required	O
to	O
be	O
non-negative	O
,	O
the	O
amortized	B-General_Concept
cost	O
is	O
an	O
upper	O
bound	O
on	O
the	O
actual	O
cost	O
.	O
</s>
<s>
The	O
potential	B-General_Concept
method	I-General_Concept
is	O
a	O
form	O
of	O
the	O
accounting	B-General_Concept
method	I-General_Concept
where	O
the	O
saved	O
credit	O
is	O
computed	O
as	O
a	O
function	O
(	O
the	O
"	O
potential	O
"	O
)	O
of	O
the	O
state	B-Application
of	O
the	O
data	B-General_Concept
structure	I-General_Concept
.	O
</s>
<s>
The	O
amortized	B-General_Concept
cost	O
is	O
the	O
immediate	O
cost	O
plus	O
the	O
change	O
in	O
potential	O
.	O
</s>
<s>
Consider	O
a	O
dynamic	B-Data_Structure
array	I-Data_Structure
that	O
grows	O
in	O
size	O
as	O
more	O
elements	O
are	O
added	O
to	O
it	O
,	O
such	O
as	O
in	O
Java	O
or	O
in	O
C++	O
.	O
</s>
<s>
If	O
we	O
started	O
out	O
with	O
a	O
dynamic	B-Data_Structure
array	I-Data_Structure
of	O
size	O
4	O
,	O
we	O
could	O
push	O
4	O
elements	O
onto	O
it	O
,	O
and	O
each	O
operation	O
would	O
take	O
constant	O
time	O
.	O
</s>
<s>
Since	O
there	O
were	O
n	O
+	O
1	O
operations	O
total	O
we	O
can	O
take	O
the	O
average	O
of	O
this	O
and	O
find	O
that	O
pushing	O
elements	O
onto	O
the	O
dynamic	B-Data_Structure
array	I-Data_Structure
takes	O
:	O
,	O
constant	O
time	O
.	O
</s>
<s>
Shown	O
is	O
a	O
Ruby	O
implementation	O
of	O
a	O
Queue	B-Application
,	O
a	O
FIFO	B-Operating_System
data	I-Operating_System
structure	I-Operating_System
:	O
</s>
<s>
Thus	O
,	O
we	O
can	O
perform	O
a	O
sequence	O
of	O
n	O
dequeue	O
operations	O
in	O
only	O
time	O
,	O
which	O
implies	O
that	O
the	O
amortized	B-General_Concept
time	I-General_Concept
of	O
each	O
dequeue	O
operation	O
is	O
.	O
</s>
<s>
This	O
charging	O
scheme	O
doubles	O
the	O
amortized	B-General_Concept
time	I-General_Concept
for	O
enqueue	O
but	O
reduces	O
the	O
amortized	B-General_Concept
time	I-General_Concept
for	O
dequeue	O
to	O
.	O
</s>
<s>
In	O
common	O
usage	O
,	O
an	O
"	O
amortized	B-General_Concept
algorithm	O
"	O
is	O
one	O
that	O
an	O
amortized	B-General_Concept
analysis	I-General_Concept
has	O
shown	O
to	O
perform	O
well	O
.	O
</s>
<s>
Online	B-Algorithm
algorithms	I-Algorithm
commonly	O
use	O
amortized	B-General_Concept
analysis	I-General_Concept
.	O
</s>
