知识卡片
栈按后进先出移除
栈规定删除最近插入的元素,即后进先出。
数组实现用 top 指向当前栈顶;push 先增 top 再写入,pop 先减 top 再返回旧栈顶。
top=0 表示空,top 达容量时再压入会溢出。
移除后旧值仍在数组槽位,不再属于栈。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
- · 栈按后进先出移除
原书出处 · 1 处
- 第10章 基本数据结构 · 查看原书依据
In a stack, the element deleted from the set is the one most recently inserted
参考来源
- 位置:《算法导论(第4版)》第 10 章 10.1.3 节(`OEBPS/chapter010.xhtml`,文本字符 [5000, 8000);图 10.2/Art_P368)。
- 结论依据:原文定义 LIFO,并给出数组栈的边界、push/pop 伪代码和移除后槽位仍留值的图示。
- 原始内容:In a stack , the element deleted from the set is the one most recently inserted