MULTIPOP (accounting method) Actual costs PUSH PUSH POP MULTIPOP min(k, s) Amortized costs PUSH POP 0 opS]=1→s1 MULTIPOP O S 1
MULTIPOP (accounting method) $ 1 S top [ S] = 1 PUSH POP MULTIPOP Actual costs 1, 1, min ( k, s). PUSH POP MULTIPOP Amortized costs 2, 0, 0. $ 1 PUSH
MULTIPOP (accounting method) Actual costs PUSH PUSH PUSH POP MULTIPOP min(k, s) Amortized costs tops=3 S 1 PUSH opS=2→Ls1 POP 0 S 1 MULTIPOP O
MULTIPOP (accounting method) $ 1 $ 1 $ 1 S top [ S] = 3 PUSH POP MULTIPOP Actual costs 1, 1, min ( k, s). PUSH POP MULTIPOP Amortized costs 2, 0, 0. $ 1 + $ 1 + $ 1 top [ S] = 2 PUSH PUSH
MULTIPOP (accounting method) Actual costs POP PUSH POP MULTIPOP min(k, s) Amortized costs tops=3 S 1 PUSH opS=2→Ls1 POP 0 S 1 MULTIPOP O S1+S1+S1+SI
MULTIPOP (accounting method) $ 1 $ 1 $ 1 S top [ S] = 2 PUSH POP MULTIPOP Actual costs 1, 1, min ( k, s). PUSH POP MULTIPOP Amortized costs 2, 0, 0. $ 1 + $ 1 + $ 1 top [ S] = 3 POP + $ 1
MULTIPOP (accounting method) Actual costs MULTIPOP 2 PUSH POP MULTIPOP min(k, s) Amortized costs PUSH opS=2→Ls1 POP 0 S 1 MULTIPOP O top[S]=0一 S1+S1+S1+S1+S1+S1
MULTIPOP (accounting method) $ 1 $ 1 S top [ S] = 2 PUSH POP MULTIPOP Actual costs 1, 1, min ( k, s). PUSH POP MULTIPOP Amortized costs 2, 0, 0. top [ S] = 0 $ 1 + $ 1 + $ 1 MULTIPOP 2 + $ 1 + $ 1 + $ 1
Accounting method a We assign differing charges to different operations with some operations charged more or less than they actually cost a The amount we charge an operation is called its amortized cost a When an operations amortized cost exceeds its actual cost the difference is assigned to specific objects in the data structure as credit
Accounting method We assign differing charges to different operations, with some operations charged more or less than they actually cost. The amount we charge an operation is called its amortized cost. When an operation’s amortized cost exceeds its actual cost, the difference is assigned to specific objects in the data structure as credit