SlideShare a Scribd company logo
Amortized Computational Complexity
Abstract : A powerful technique in the complexity analysis of various algorithms is amortization
or averaging over time. Amortized running time is a realistic measure of complexity of a
sequence of operations . It will not provide you with the exact computational time . Instead , it
lets you calculate a tight upper bound and lower bound of algorithms . Based on the result
obtained, varieties of algorithms can be compared for performance analysis . This white-paper
describes several methods of evaluating amortized complexity .
Introduction : In many uses of data structures , a sequence of operations , rather than a single
operation, is performed . So, the final goal is to evaluate the amortized time complexity of that
sequence . The only requirement is that the sum of the amortized complexity of all elements in
a sequence is greater than the sum of the actual complexities of the elements . So, we can
conclude :
Sum(amortized(i)) >= Sum(actual(i)) ........... (1.1)
Relative to actual cost and amortized cost of an operation in a sequence of n operations , we
define a potential function as below :
P(i) = amortized(i) - actual (i) - P(i-1) ...........(1.2)
Taking sum of the equation , we obtain :
P(n) = Sum(amortized(i)) - Sum(actual(i)) ..........(1.3)
From (1.1) & (1.3) , we conclude :
P(n) >= 0 ........(1.4)
To make the idea of amortization and motivation behind it more concrete , let us consider the
example of evaluating the amortized complexity of an algorithm , which displays number of toys
available in binary format . To update every digit of the display the algorithm takes d unit of
time . Assuming that the number of current toys is N and initial no. of toys is 0, we need to
evaluate the amortized complexity of the algorithm used to display the number of toys . There
are three popular methods to arrive at the amortized complexity of the operations, namely , (1)
aggregate method , (2) accounting method and (3) potential method .
Aggregate Method : In the aggregate method ,we determine the
UpperBoundOnSumOfActualCosts(N) for the sum of the actual costs of the n operations.The
amortized cost is amounted to UpperBoundOnSumOfActualCosts(N) /N .
Let N be the number of toys manufactured ; the number of digits used to display the number of
toys is n or 'Base-2 logN' . The least significant bit of the display has been changed N times ; the
second digit from the right changes once for every 2 toys ; the third digit from the lright changes
once for every 4 times and so on...
So, the aggregate number of digits that have been changed is bounded by n (1+1/2+1/4+...)d or
d2n. So, the amortized cost is amounted to 2n/n = 2d.
Accounting Method : To proceed using accounting method , we must first assign an amortized
cost and then prove that this assignment satisfies eq - (1.1). Generally we start by assigning an
amortized cost obtained by a good guess . Once we have shown this , we obtain an upper bound
on the cost of any operation sequence by computing Sum(f(i)*amortized(i)) , where f(i) be the
frequency of the operation and amortized(i) the amortized cost of the operation .
Suppose , we assign a guessed amortized cost of 2d for each display change . Then the potential
function
P(n) = Sum(amortized(i)) - Sum(actual(i))
= 2dn - d(1+1/2+1/4+.......)
> = 0;
So, the accounting method proved that the amortized cost of the display can be reduced to 2d.
Potential Method : In this approach , we postulate a function for the analysis and use the
function to satisfy eq - (1) .
Consider the example given in the introduction section . When the first toy is available , we can
use the amortized cost 2d to pay for the update , in which d amount is spent and remaining d
amount is retained as a credit to the first least significant bit. Following the update of the second
digit , the amount spent is 2d*2 in which 3d is spent to update two least significant digits and
the second least significant bit now has credit d . Proceeding in this way , we can sum up credit
on each digit of the display always equal (2d-d)v , where 2d be the amortized cost , d actual cost
and v the value of the digit. So, we should use the potential function
P(n) = (2d-d)*Sum(v(i)) , where v(i) = digit value of the i-th digit
Let q be the number of 1’s at the rightmost places and the j th display and it has been changed
from jth to (j+1) th no.So, when the display changes from j th to j+1 th value, where j = 1111011
the potential change incurred
P(n) = d(1-q*1) ;
So the amortized cost for the display change = actual cost + p(n) = (q+1)d +P(n) = (q+1)d + d(1-
2*1) = 2d .
Conclusion : A worst case analysis ,in which we sum the worst-case time of individual
operations, may be unduly pessimistic ; it ignores correlated effect on data structures. On the
other hand, average case analysis can be inaccurate , as the probabilistic assumptions needed to
carry out the analysis may be false . In such a scenario, amortized analysis , in which we average
the running time over per operation , yield an answer that is both realistic and robust .

More Related Content

RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
RTF
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity
Amortized complexity

What's hot (19)

PPT
Amortized Analysis of Algorithms
PDF
09. amortized analysis
PPT
Amortized analysis
PDF
13 Amortized Analysis
RTF
Amortized complexity
PPT
Aoa amortized analysis
PPT
Amortized
PPT
Amortized Analysis
PPTX
Adauctions
PDF
12 Greeddy Method
PDF
Synchronous Loadable Up and Down Counter
DOCX
BIometrics- plotting DET and EER curve using Matlab
PDF
Nrtl activity coefficient for mixture1
PPT
Solving a “Transportation Planning” Problem through the Programming Language “C”
PPTX
A star
PDF
Hw5 2017-spring
PPTX
Dynamic Program Problems
PPT
Amortized analysis
Amortized Analysis of Algorithms
09. amortized analysis
Amortized analysis
13 Amortized Analysis
Amortized complexity
Aoa amortized analysis
Amortized
Amortized Analysis
Adauctions
12 Greeddy Method
Synchronous Loadable Up and Down Counter
BIometrics- plotting DET and EER curve using Matlab
Nrtl activity coefficient for mixture1
Solving a “Transportation Planning” Problem through the Programming Language “C”
A star
Hw5 2017-spring
Dynamic Program Problems
Amortized analysis
Ad

Viewers also liked (13)

DOCX
CV NETSANET SINTAYEHU
PPTX
презентация It школа 2015
PPS
Si me ves
PPTX
|RECICLAJE DEL COBRE|EST 29|
PPT
Srećna Nova 2016
PPTX
Buzz Nuts Test
PPTX
Los diarios digitales
PPT
Сеть семейных клиник Доктор Рядом
PPTX
Training And Certification Presentation Jordan
PPTX
Kompozicija i nijanse boja (jesenski pejzaž-4.r.)
PPTX
Microstructure and chemical compositions of ferritic stainless steel
PPT
Albanija Tanja Notaroš Gagić
DOCX
Graphical success illustrations
CV NETSANET SINTAYEHU
презентация It школа 2015
Si me ves
|RECICLAJE DEL COBRE|EST 29|
Srećna Nova 2016
Buzz Nuts Test
Los diarios digitales
Сеть семейных клиник Доктор Рядом
Training And Certification Presentation Jordan
Kompozicija i nijanse boja (jesenski pejzaž-4.r.)
Microstructure and chemical compositions of ferritic stainless steel
Albanija Tanja Notaroš Gagić
Graphical success illustrations
Ad

Similar to Amortized complexity (20)

PPTX
AA_Unit 1_part-I.pptx
PPT
Amortized analysis
PPTX
DOC-20230417-WA0013.-7-27.pptx
PDF
Amortize full greedy and Analysis.pptx.pdf
PPTX
Amortized analysis
PDF
Amortized Analysis in Advanced Data Structure
PDF
AA_Unit 1_part-II.pdf
PDF
AmortizedAnalysis
PDF
Bellmon Ford Algorithm
PPTX
Design and Analysis of Algorithms.pptx
PPT
introduction to data structure is providing a basic
PDF
exam6.pdf
PPTX
Performance analysis and randamized agoritham
PDF
Algorithms Analysis.pdf
PDF
A gentle introduction to algorithm complexity analysis
PDF
Advanced Algorithms Lecture Notes Mit 6854j Itebooks
PDF
(1) collections algorithms
PPT
Amortized analysis
PPTX
Design & Analysis of Algorithm course .pptx
PPT
Eit orginal
AA_Unit 1_part-I.pptx
Amortized analysis
DOC-20230417-WA0013.-7-27.pptx
Amortize full greedy and Analysis.pptx.pdf
Amortized analysis
Amortized Analysis in Advanced Data Structure
AA_Unit 1_part-II.pdf
AmortizedAnalysis
Bellmon Ford Algorithm
Design and Analysis of Algorithms.pptx
introduction to data structure is providing a basic
exam6.pdf
Performance analysis and randamized agoritham
Algorithms Analysis.pdf
A gentle introduction to algorithm complexity analysis
Advanced Algorithms Lecture Notes Mit 6854j Itebooks
(1) collections algorithms
Amortized analysis
Design & Analysis of Algorithm course .pptx
Eit orginal

Recently uploaded (20)

PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PPTX
Construction Project Organization Group 2.pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
PPT on Performance Review to get promotions
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPT
Total quality management ppt for engineering students
PPTX
Geodesy 1.pptx...............................................
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
III.4.1.2_The_Space_Environment.p pdffdf
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Fundamentals of Mechanical Engineering.pptx
Safety Seminar civil to be ensured for safe working.
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Construction Project Organization Group 2.pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPT on Performance Review to get promotions
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Total quality management ppt for engineering students
Geodesy 1.pptx...............................................
Internet of Things (IOT) - A guide to understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks

Amortized complexity

  • 1. Amortized Computational Complexity Abstract : A powerful technique in the complexity analysis of various algorithms is amortization or averaging over time. Amortized running time is a realistic measure of complexity of a sequence of operations . It will not provide you with the exact computational time . Instead , it lets you calculate a tight upper bound and lower bound of algorithms . Based on the result obtained, varieties of algorithms can be compared for performance analysis . This white-paper describes several methods of evaluating amortized complexity . Introduction : In many uses of data structures , a sequence of operations , rather than a single operation, is performed . So, the final goal is to evaluate the amortized time complexity of that sequence . The only requirement is that the sum of the amortized complexity of all elements in a sequence is greater than the sum of the actual complexities of the elements . So, we can conclude : Sum(amortized(i)) >= Sum(actual(i)) ........... (1.1) Relative to actual cost and amortized cost of an operation in a sequence of n operations , we define a potential function as below : P(i) = amortized(i) - actual (i) - P(i-1) ...........(1.2) Taking sum of the equation , we obtain : P(n) = Sum(amortized(i)) - Sum(actual(i)) ..........(1.3) From (1.1) & (1.3) , we conclude : P(n) >= 0 ........(1.4) To make the idea of amortization and motivation behind it more concrete , let us consider the example of evaluating the amortized complexity of an algorithm , which displays number of toys available in binary format . To update every digit of the display the algorithm takes d unit of time . Assuming that the number of current toys is N and initial no. of toys is 0, we need to evaluate the amortized complexity of the algorithm used to display the number of toys . There are three popular methods to arrive at the amortized complexity of the operations, namely , (1) aggregate method , (2) accounting method and (3) potential method .
  • 2. Aggregate Method : In the aggregate method ,we determine the UpperBoundOnSumOfActualCosts(N) for the sum of the actual costs of the n operations.The amortized cost is amounted to UpperBoundOnSumOfActualCosts(N) /N . Let N be the number of toys manufactured ; the number of digits used to display the number of toys is n or 'Base-2 logN' . The least significant bit of the display has been changed N times ; the second digit from the right changes once for every 2 toys ; the third digit from the lright changes once for every 4 times and so on... So, the aggregate number of digits that have been changed is bounded by n (1+1/2+1/4+...)d or d2n. So, the amortized cost is amounted to 2n/n = 2d. Accounting Method : To proceed using accounting method , we must first assign an amortized cost and then prove that this assignment satisfies eq - (1.1). Generally we start by assigning an amortized cost obtained by a good guess . Once we have shown this , we obtain an upper bound on the cost of any operation sequence by computing Sum(f(i)*amortized(i)) , where f(i) be the frequency of the operation and amortized(i) the amortized cost of the operation . Suppose , we assign a guessed amortized cost of 2d for each display change . Then the potential function P(n) = Sum(amortized(i)) - Sum(actual(i)) = 2dn - d(1+1/2+1/4+.......) > = 0; So, the accounting method proved that the amortized cost of the display can be reduced to 2d.
  • 3. Potential Method : In this approach , we postulate a function for the analysis and use the function to satisfy eq - (1) . Consider the example given in the introduction section . When the first toy is available , we can use the amortized cost 2d to pay for the update , in which d amount is spent and remaining d amount is retained as a credit to the first least significant bit. Following the update of the second digit , the amount spent is 2d*2 in which 3d is spent to update two least significant digits and the second least significant bit now has credit d . Proceeding in this way , we can sum up credit on each digit of the display always equal (2d-d)v , where 2d be the amortized cost , d actual cost and v the value of the digit. So, we should use the potential function P(n) = (2d-d)*Sum(v(i)) , where v(i) = digit value of the i-th digit Let q be the number of 1’s at the rightmost places and the j th display and it has been changed from jth to (j+1) th no.So, when the display changes from j th to j+1 th value, where j = 1111011 the potential change incurred P(n) = d(1-q*1) ; So the amortized cost for the display change = actual cost + p(n) = (q+1)d +P(n) = (q+1)d + d(1- 2*1) = 2d .
  • 4. Conclusion : A worst case analysis ,in which we sum the worst-case time of individual operations, may be unduly pessimistic ; it ignores correlated effect on data structures. On the other hand, average case analysis can be inaccurate , as the probabilistic assumptions needed to carry out the analysis may be false . In such a scenario, amortized analysis , in which we average the running time over per operation , yield an answer that is both realistic and robust .