- 聚合分析
- 核算法
- 势能法
c ^ i − c i = c r e d i t = Φ ( D i ) − Φ ( D i − 1 ) \hat c_i - c_i = credit = \Phi (D_i)- \Phi (D_{i-1}) c^i−ci=credit=Φ(Di)−Φ(Di−1)
∑ c ^ i = ∑ c i + Φ ( D − i ) − Φ ( D i − 1 ) \sum \hat c_i = \sum c_i + \Phi(D-i) - \Phi(D_{i-1}) ∑c^i=∑ci+Φ(D−i)−Φ(Di−1)
合并两个skew heap摊还时间为O(logN)
exercises
C
A light child has at most half weight of its parents. Thus if there are k light nodes not including x along the path from x to y, w ( y ) ≤ w ( x ) / 2 k w(y) \leq w(x)/2^k w(y)≤w(x)/2k ( k ≤ l o g w ( x ) w ( y ) k \leq log \frac{w(x)}{w(y)} k≤logw(y)w(x) )
Φ \Phi Φ = the total number of right heavy nodes it contains
By lemma 2, any path in a skew heap contains only O(logn) light nodes
Any heavy node on such a path is converted from right to left by causing a drop of one in the potential
Two heaps h 1 h_1 h1 and h 2 h_2 h2, containing n 1 n_1 n1 and n 2 n_2 n2 items
n = n 1 + n 2 n = n_1 + n_2 n=n1+n2
By lemma 1, the total number of light nodes is at most 2 ⌊ l o g n ⌋ − 1 2 \lfloor logn \rfloor -1 2⌊logn⌋−1
Let k 1 k_1 k1 and k 2 k_2 k2 be the number of heavy nodes on the right path of h 1 h_1 h1 and h 2 h_2 h2, and k 3 k_3 k3 be the number of nodes that become right heavy children of nodes on the merge path.
By lemma 2, k 3 ≤ ⌊ l o g n ⌋ k_3 \leq \lfloor logn \rfloor k3≤⌊logn⌋
the number of node on the merge path is at most
c i ≤ 2 + ⌊ l o g n 1 ⌋ + k 1 + ⌊ l o g n 2 ⌋ + k 2 ≤ 1 + 2 ⌊ l o g n ⌋ + k 1 + k 2 c_i \leq 2+ \lfloor logn_1 \rfloor + k_1 + \lfloor logn_2 \rfloor + k_2 \leq 1 + 2 \lfloor logn \rfloor + k_1 + k_2 ci≤2+⌊logn1⌋+k1+⌊logn2⌋+k2≤1+2⌊logn⌋+k1+k2
The increase in the potential caused by the merge is Δ Φ = k 3 − k 2 − k 1 = ⌊ l o g n ⌋ − k 1 − k 2 \Delta \Phi = k_3 - k_2 - k_1 = \lfloor logn \rfloor - k_1 - k_2 ΔΦ=k3−k2−k1=⌊logn⌋−k1−k2
This the amortized is at most 3 ⌊ l o g n ⌋ + 1 3 \lfloor logn \rfloor + 1 3⌊logn⌋+1