






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Course: Algorithms These notes described Amortized Analysis in Algorithms
Typology: Slides
1 / 30
This page cannot be seen from the preview
Don't miss anything!
No involvement of probability
Average performance on a sequence of operations,
even if some operation is expensive
Guarantee average performance of each operation
among the sequence in worst case
Methods of Amortized Analysis
bound T(n) on the total sequence of n operations.
The cost of each will then be T(n)/n.
We overcharge some operations early and use
them to as prepaid charge later for other
operations.
potential energy associated with the structure as
a whole.
Sequence of n push, pop, Multipop
operations
Worst-case cost of Multipop is O(n)
Have n operations
Therefore, worst-case cost of sequence is
O(n
2
)
1
0
k
i
i
Aggregate Method for k-Bit Counter
occurs when all k bits are flipped
them will cause all k bits to flip
-th increment
Accounting Method
an object in the data structure
make up the difference
i
is the actual cost and c
i
^ is the amortized cost then,
we must ensure that for all n :
on the total true costs.
Accounting Method: Stack Example
3 ops:
Push(S,x) Pop(S) Multi-pop(S,k)
•Assigned
cost:
2 0 0
•Actual cost: 1 1 min(|S|,k)
Note: Push(S,x) pays for possible later pop of x.
CPSC 411, Fall 2008: Set 6 19
Accounting Method for k-Bit Counter
When Incrementing,
Amortized cost for INCREMENT(A) = Rs.
Amortized cost for n INCREMENT(A) = Rs.2n =O(n)