知识卡片
伪代码的索引与引用语义须先核对
把书中伪代码改写成程序前,先核对数组起点、切片终点和对象传参语义。
本书的 A[i:j] 包含 j;对象参数复制的是引用,重绑形参不影响调用者,修改共享对象的属性或数组元素则会影响调用者。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第2章 算法入门 · 查看原书依据
The notation “:” denotes a subarray. Thus, A[i : j] indicates the subarray of A consisting of the elements A[i], A[i + 1],
参考来源
- 位置:《算法导论(第4版)》第 2 章 2.1 节“Pseudocode conventions”(`OEBPS/chapter002.xhtml`)。
- 结论依据:原文明确说明子数组闭区间、对象和数组的引用赋值以及参数按值传递。
- 原始内容:The notation “:” denotes a subarray. Thus, A [ i : j ] indicates the subarray of A consisting of the elements A [ i ], A [ i + 1], … , A [ j ].