知识卡片
倍增插入总成本线性
只插入且满时倍增的动态表,一次扩容需复制许多旧项,但扩容发生在容量为2的幂次时。
n次插入的普通插入成本为n,历次复制量构成几何级数且小于2n,因此总成本小于3n,每次摊还不超过常数。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第16章 摊还分析 · 查看原书依据
Since the total cost of n TABLE-INSERT operations is bounded by 3n, the amortized cost of a single operation is at most 3.
参考来源
- 位置:《算法导论(第4版)》第16章《摊还分析》(OEBPS/chapter016.xhtml,文本字符[30000,35000))。
- 结论依据:16.4.1 节对 n 次插入将基本插入的 n 与容量按2的幂增长时的复制量相加,得到总成本≤3n,所以每次摊还≤3。
- 原始内容:Since the total cost of n T ABLE -I NSERT operations is bounded by 3 n , the amortized cost of a single operation is at most 3.