Amortized analysis

在这里插入图片描述

  • 聚合分析
  • 核算法
  • 势能法
    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^ici=credit=Φ(Di)Φ(Di1)
    ∑ 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+Φ(Di)Φ(Di1)

合并两个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)} klogw(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 2logn1
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 k3logn
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 ci2+logn1+k1+logn2+k21+2logn+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 ΔΦ=k3k2k1=lognk1k2
This the amortized is at most 3 ⌊ l o g n ⌋ + 1 3 \lfloor logn \rfloor + 1 3logn+1

https://blog.csdn.net/Woolseyyy/article/details/51517446

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值