Algorithms and Data Structures · Senior · Question 28 of 75

What is amortized analysis with the "accounting" or "potential" method?

Explanation

It gives a worst-case bound for a sequence of operations, with no probability involved. Each push to a dynamic array "saves" a constant that later pays for copying during a resize. Averaging over random inputs is average-case analysis, a different thing.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 28

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz