SlideShare a Scribd company logo
1 of 4
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 least significant bit changes once for every 2 toys ; the third least significant bit 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 2dN/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; (P(n) converges to ‘0’ ,. Hence , it fulfills the requirement of amortized complexity ) .
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
toy , 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 and the first least significant bit has credit 0 .
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 the 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) = face 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) - P(N-1)= d(1-q*1) ;
So the amortized cost for the display change = actual cost + P(N) - P(N-1)= (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

What's hot

Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Electrical Engineering Exam Help
Electrical Engineering Exam HelpElectrical Engineering Exam Help
Electrical Engineering Exam HelpLive Exam Helper
 
Computing Information Flow Using Symbolic-Model-Checking_.pdf
Computing Information Flow Using Symbolic-Model-Checking_.pdfComputing Information Flow Using Symbolic-Model-Checking_.pdf
Computing Information Flow Using Symbolic-Model-Checking_.pdfPolytechnique Montréal
 
BIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabBIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabShiv Koppad
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CMeghaj Mallick
 
Introduction to Approximation Algorithms
Introduction to Approximation AlgorithmsIntroduction to Approximation Algorithms
Introduction to Approximation AlgorithmsJhoirene Clemente
 

What's hot (19)

Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized analysis
Amortized analysisAmortized analysis
Amortized analysis
 
Electrical Engineering Exam Help
Electrical Engineering Exam HelpElectrical Engineering Exam Help
Electrical Engineering Exam Help
 
Computing Information Flow Using Symbolic-Model-Checking_.pdf
Computing Information Flow Using Symbolic-Model-Checking_.pdfComputing Information Flow Using Symbolic-Model-Checking_.pdf
Computing Information Flow Using Symbolic-Model-Checking_.pdf
 
BIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabBIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using Matlab
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using C
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Chap07alg
Chap07algChap07alg
Chap07alg
 
Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 
Introduction to Approximation Algorithms
Introduction to Approximation AlgorithmsIntroduction to Approximation Algorithms
Introduction to Approximation Algorithms
 

Viewers also liked

03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic AnalysisAndres Mendez-Vazquez
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAmrinder Arora
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codeshermiraguilar
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 

Viewers also liked (11)

03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Big o notation
Big o notationBig o notation
Big o notation
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 

Similar to Amortized complexity

DOC-20230417-WA0013.-7-27.pptx
DOC-20230417-WA0013.-7-27.pptxDOC-20230417-WA0013.-7-27.pptx
DOC-20230417-WA0013.-7-27.pptx03Shrishti
 
5.2 Least Squares Linear Regression.pptx
5.2  Least Squares Linear Regression.pptx5.2  Least Squares Linear Regression.pptx
5.2 Least Squares Linear Regression.pptxMaiEllahham1
 
Basic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusBasic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusNANDINI SHARMA
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Vai Jayanthi
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexityAbbas Ali
 
economic load dispatch and unit commitment power_system_operation.pdf
economic load dispatch and unit commitment power_system_operation.pdfeconomic load dispatch and unit commitment power_system_operation.pdf
economic load dispatch and unit commitment power_system_operation.pdfArnabChakraborty499766
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Unit i basic concepts of algorithms
Unit i basic concepts of algorithmsUnit i basic concepts of algorithms
Unit i basic concepts of algorithmssangeetha s
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMSTanya Makkar
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...2022cspaawan12556
 
WVKULAK13_submission_14
WVKULAK13_submission_14WVKULAK13_submission_14
WVKULAK13_submission_14Max De Koninck
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesHaitham El-Ghareeb
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsMAHERMOHAMED27
 

Similar to Amortized complexity (20)

DOC-20230417-WA0013.-7-27.pptx
DOC-20230417-WA0013.-7-27.pptxDOC-20230417-WA0013.-7-27.pptx
DOC-20230417-WA0013.-7-27.pptx
 
Bellmon Ford Algorithm
Bellmon Ford AlgorithmBellmon Ford Algorithm
Bellmon Ford Algorithm
 
5.2 Least Squares Linear Regression.pptx
5.2  Least Squares Linear Regression.pptx5.2  Least Squares Linear Regression.pptx
5.2 Least Squares Linear Regression.pptx
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Basic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusBasic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV Syllabus
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
economic load dispatch and unit commitment power_system_operation.pdf
economic load dispatch and unit commitment power_system_operation.pdfeconomic load dispatch and unit commitment power_system_operation.pdf
economic load dispatch and unit commitment power_system_operation.pdf
 
Slide2
Slide2Slide2
Slide2
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Unit i basic concepts of algorithms
Unit i basic concepts of algorithmsUnit i basic concepts of algorithms
Unit i basic concepts of algorithms
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
 
WVKULAK13_submission_14
WVKULAK13_submission_14WVKULAK13_submission_14
WVKULAK13_submission_14
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elements
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 

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 least significant bit changes once for every 2 toys ; the third least significant bit 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 2dN/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; (P(n) converges to ‘0’ ,. Hence , it fulfills the requirement of amortized complexity ) . 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 toy , 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 and the first least significant bit has credit 0 . 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 the 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) = face 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) - P(N-1)= d(1-q*1) ; So the amortized cost for the display change = actual cost + P(N) - P(N-1)= (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 .