Complexity Analysis Flashcards
Accumulation technique
Show that n actions cost T(n) so therefore a single action costs T(n)/n
Charging technique
Ramp up the “price” of using “cheap” operations, that way the “price” of the expensive ones cancel out with the cheaper ones.
The potential method
Create a function that reflects the potential that the data structure has.
The function for a single action wil be:
C = actual_cost + P(Di) - P(Di-1)
P(Dn) >= P(0)
Proving correctness of Potential function
To prove the correctness of a potential function:
1. Prove that the value is non negative.
2. Prove that the complexity is as wanted.
Dynamic list (idea)
We have a list but we don’t know how many items it will have. Solution: double the list’s size every time it is full.
Dynamic list analysis
Takes O(1) for all actions. Using the charging method, each action costs 3 to pay for all of the items behind it.