mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-03 07:01:55 +08:00
Update stack.md
This commit is contained in:
parent
f2e9e8f28f
commit
2890771d93
@ -6,7 +6,9 @@ comments: true
|
||||
|
||||
「栈 Stack」是一种遵循「先入后出 first in, last out」数据操作规则的线性数据结构。我们可以将栈类比为放在桌面上的一摞盘子,如果需要拿出底部的盘子,则需要先将上面的盘子依次取出。
|
||||
|
||||
我们将顶部盘子称为「栈顶」,底部盘子称为「栈底」,将把元素添加到栈顶的操作称为「入栈」,将删除栈顶元素的操作称为「出栈」。
|
||||
“盘子”是一种形象比喻,我们将盘子替换为任意一种元素(例如整数、字符、对象等),就得到了栈数据结构。
|
||||
|
||||
我们将这一摞元素的顶部称为「栈顶」,将底部称为「栈底」,将把元素添加到栈顶的操作称为「入栈」,将删除栈顶元素的操作称为「出栈」。
|
||||
|
||||
![stack_operations](stack.assets/stack_operations.png)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user