





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























Each object can be POP only once (including in MULTIPOP) for each time it is PUSHed. #POPs is at most #PUSHs, which is at most n. Thus the average cost of an operation is O ( n )/ n = O (1). Amortized cost in aggregate analysis is defined to be average cost.
Another example: increasing a binary counter
Amortized (Aggregate) Analysis of INCREMENT(A) Observation: The running time determined by #flips but not all bits flip each time INCREMENT is called. A[0] flips every time, total n times. A[1] flips every other time, n /2 times. A[2] flips every forth time, n /4 times. …. for i =0,1,…, k -1, A[ i ] flips n / i times. Thus total #flips is i = k - n / i < n i = 1/ i = 2 n.
Accounting Method (cont.)
Potential method: stack operation
Potential method: binary counter
Dynamic table: expansion with insertion