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 whitepaper
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 left changes once for every 2 toys ; the third digit from the left 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 digit from the left . Following the update of the second
digit , the amount spent is 2d*2 in which 2d is spent to update two leftmost digits and the
second digit from left now has credit 2d . Proceeding in this way , we can sum up credit on each
digit of the display always equal 2dv , where 2d is the amortized cost and v the value of the digit.
So, we should use the potential function
P(n) = 2d*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) = 2d(1-2*1) ;
So the amortized cost for the display change = actual cost + p(n) = (q+1)d +P(n) = (q+1)d + 2d(1-
2*1).
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

What's hot (18)

PDF
09. amortized analysis
Onkar Nath Sharma
 
PPT
Amortized analysis
ajmalcs
 
PPT
Aoa amortized analysis
Salabat Khan
 
PPT
Amortized
8neutron8
 
PDF
13 Amortized Analysis
Andres Mendez-Vazquez
 
PPT
Amortized Analysis
sathish sak
 
PPTX
Adauctions
超 刘
 
PDF
Nrtl activity coefficient for mixture1
ESSID Abou Hligha
 
PDF
Synchronous Loadable Up and Down Counter
Digital System Design
 
PPT
Solving a “Transportation Planning” Problem through the Programming Language “C”
Shahadat Hossain Shakil
 
PPTX
A star
minhaz uddin
 
PDF
Hw5 2017-spring
奕安 陳
 
PPT
Amortized analysis
mohit tripathi
 
PDF
Vb scripting
Rajanikanth Bandela
 
DOCX
Write a program to print out all armstrong numbers between 1 and 500
ilsamaryum
 
PPTX
Topic 1.2
Sue Whale
 
PPTX
Dynamic Program Problems
Ranjit Sasmal
 
PPTX
Matlab Feature Extraction Using Segmentation And Edge Detection
DataminingTools Inc
 
09. amortized analysis
Onkar Nath Sharma
 
Amortized analysis
ajmalcs
 
Aoa amortized analysis
Salabat Khan
 
Amortized
8neutron8
 
13 Amortized Analysis
Andres Mendez-Vazquez
 
Amortized Analysis
sathish sak
 
Adauctions
超 刘
 
Nrtl activity coefficient for mixture1
ESSID Abou Hligha
 
Synchronous Loadable Up and Down Counter
Digital System Design
 
Solving a “Transportation Planning” Problem through the Programming Language “C”
Shahadat Hossain Shakil
 
A star
minhaz uddin
 
Hw5 2017-spring
奕安 陳
 
Amortized analysis
mohit tripathi
 
Vb scripting
Rajanikanth Bandela
 
Write a program to print out all armstrong numbers between 1 and 500
ilsamaryum
 
Topic 1.2
Sue Whale
 
Dynamic Program Problems
Ranjit Sasmal
 
Matlab Feature Extraction Using Segmentation And Edge Detection
DataminingTools Inc
 

Viewers also liked (17)

DOCX
NPI Letter of Recommendation_Stefan Holmes
Stefan Holmes
 
PDF
LoR-Adams
Scott Shafer
 
PPTX
¿Que hemos hecho en escuela nueva año 2016, sede el rosal?
Maria Isabel Camargo Guio
 
PPTX
Perfect passive
Edward Freire
 
PDF
السيره الذاتيه الاصليه
Nashmi Alrashedi
 
PDF
Revisión uno
Ivan Vladimir Meza-Ruiz
 
PPT
Violência Gratuita (Funny Games – 1997)
Paola Giovana
 
PPSX
Cabalgata del bicentenario
Miguel Rivera
 
PPT
Minerals & Rocks
ticbilingue
 
PPTX
Проект "Палеозойська ера"
ZAVERTKIN
 
PPTX
Wiki presentation
ebuckingham-jones
 
PPT
πολιτιστικο προγραμμα χοροι(niki)
Mario Vag
 
DOCX
Antologia cuento corrido leyenda descripción
Josue Gonzalez
 
DOCX
Desafíos matemáticos 4 5 6 copia
MISAEL LOPEZ HERNANDEZ
 
DOCX
Síntesis del diario.
reynate
 
PPTX
Будова кісткової, хрящової та м'язової тканин
labinskiir-33
 
PDF
Auditoria Administrativa Bimbo
renehdezlpz
 
NPI Letter of Recommendation_Stefan Holmes
Stefan Holmes
 
LoR-Adams
Scott Shafer
 
¿Que hemos hecho en escuela nueva año 2016, sede el rosal?
Maria Isabel Camargo Guio
 
Perfect passive
Edward Freire
 
السيره الذاتيه الاصليه
Nashmi Alrashedi
 
Violência Gratuita (Funny Games – 1997)
Paola Giovana
 
Cabalgata del bicentenario
Miguel Rivera
 
Minerals & Rocks
ticbilingue
 
Проект "Палеозойська ера"
ZAVERTKIN
 
Wiki presentation
ebuckingham-jones
 
πολιτιστικο προγραμμα χοροι(niki)
Mario Vag
 
Antologia cuento corrido leyenda descripción
Josue Gonzalez
 
Desafíos matemáticos 4 5 6 copia
MISAEL LOPEZ HERNANDEZ
 
Síntesis del diario.
reynate
 
Будова кісткової, хрящової та м'язової тканин
labinskiir-33
 
Auditoria Administrativa Bimbo
renehdezlpz
 
Ad

Similar to Amortized complexity (20)

RTF
Amortized complexity
paramita30
 
PPT
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
PPTX
DOC-20230417-WA0013.-7-27.pptx
03Shrishti
 
PPTX
5.2 Least Squares Linear Regression.pptx
MaiEllahham1
 
PDF
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
DOCX
Basic Computer Engineering Unit II as per RGPV Syllabus
NANDINI SHARMA
 
PDF
Cs6402 daa-2 marks set 1
Vai Jayanthi
 
PPT
Big-O notations, Algorithm and complexity analaysis
drsomya2019
 
PPT
Lec03 04-time complexity
Abbas Ali
 
PPT
Asymptotic Notation
Lovely Professional University
 
PPT
algo_vc_lecture8.ppt
Nehagupta259541
 
PDF
WVKULAK13_submission_14
Max De Koninck
 
PPT
Big Oh.ppt
Senthil Vit
 
PPTX
Asymptotic Analysis in Data Structure using C
Meghaj Mallick
 
PPTX
Dynamic programming1
debolina13
 
PPT
Slide2
Thiti Sununta
 
PPTX
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
PPTX
Unit i basic concepts of algorithms
sangeetha s
 
PDF
economic load dispatch and unit commitment power_system_operation.pdf
ArnabChakraborty499766
 
PDF
Bellmon Ford Algorithm
69RishabhPandey
 
Amortized complexity
paramita30
 
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
DOC-20230417-WA0013.-7-27.pptx
03Shrishti
 
5.2 Least Squares Linear Regression.pptx
MaiEllahham1
 
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
Basic Computer Engineering Unit II as per RGPV Syllabus
NANDINI SHARMA
 
Cs6402 daa-2 marks set 1
Vai Jayanthi
 
Big-O notations, Algorithm and complexity analaysis
drsomya2019
 
Lec03 04-time complexity
Abbas Ali
 
Asymptotic Notation
Lovely Professional University
 
algo_vc_lecture8.ppt
Nehagupta259541
 
WVKULAK13_submission_14
Max De Koninck
 
Big Oh.ppt
Senthil Vit
 
Asymptotic Analysis in Data Structure using C
Meghaj Mallick
 
Dynamic programming1
debolina13
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
Unit i basic concepts of algorithms
sangeetha s
 
economic load dispatch and unit commitment power_system_operation.pdf
ArnabChakraborty499766
 
Bellmon Ford Algorithm
69RishabhPandey
 
Ad

Recently uploaded (20)

PPTX
quantum computing transition from classical mechanics.pptx
gvlbcy
 
PPTX
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
PDF
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
PPTX
cybersecurityandthe importance of the that
JayachanduHNJc
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PPTX
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
PDF
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
PPTX
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
PDF
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
quantum computing transition from classical mechanics.pptx
gvlbcy
 
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
cybersecurityandthe importance of the that
JayachanduHNJc
 
Zero Carbon Building Performance standard
BassemOsman1
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
Information Retrieval and Extraction - Module 7
premSankar19
 
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 

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 whitepaper 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 left changes once for every 2 toys ; the third digit from the left 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 digit from the left . Following the update of the second digit , the amount spent is 2d*2 in which 2d is spent to update two leftmost digits and the second digit from left now has credit 2d . Proceeding in this way , we can sum up credit on each digit of the display always equal 2dv , where 2d is the amortized cost and v the value of the digit. So, we should use the potential function P(n) = 2d*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) = 2d(1-2*1) ; So the amortized cost for the display change = actual cost + p(n) = (q+1)d +P(n) = (q+1)d + 2d(1- 2*1).
  • 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 .