Amortized Analysis¶
Target¶
Any M consecutive tree operations starting from an empty tree take at most \(O(M \log N)\) time.
We have this: $$ worst\; case\; bound \geq amortized\; bound \geq average \; case\; bound $$
Aggregate Analysis(总量分析)¶
Idea¶
Accounting method(会计法)¶
Notice that:
Ex: Stack with MultiPop
BUT: The most difficult part of amortized method is to guess the amortized cost
Potential method(势能法)¶
Idea¶
- 所以究竟什么是信用?信用是这个操作把问题结构改变了多少
- we have to guess a good potantial function for the current problem structure
- So a good potential function requires that the first element \(\phi(D_0)\)
Ex: Stack with MultiPop(int k, Stack S)
Ex: Splay Trees¶
$$
\hat{c_i} \leq 1+3(R_2(X)-R_1(X))
$$
- 所以总和最大就是\(1+3(R_N(X)-R_1(X))\),也就是\(O(\log N)\)
Problem¶
1¶
When doing amortized analysis, which one of the following statements is FALSE?
B
The "maximum" is wrong, it should be "minimum".
2¶
A. The number of items currently in the buffer
B. The opposite number of items currently in the buffer
C. The number of available blocks currently in the buffer
D. The opposite number of available blocks in the buffer
D