mirror of
https://github.com/krahets/hello-algo.git
synced 2025-08-02 11:33:18 +08:00
build
This commit is contained in:
@ -10,7 +10,7 @@ comments: true
|
||||
|
||||
如图 5-1 所示,我们把堆叠元素的顶部称为“栈顶”,底部称为“栈底”。将把元素添加到栈顶的操作叫做“入栈”,删除栈顶元素的操作叫做“出栈”。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-1 栈的先入后出规则 </p>
|
||||
|
||||
@ -325,13 +325,13 @@ comments: true
|
||||
如图 5-2 所示,对于入栈操作,我们只需将元素插入链表头部,这种节点插入方法被称为“头插法”。而对于出栈操作,只需将头节点从链表中删除即可。
|
||||
|
||||
=== "LinkedListStack"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-2 基于链表实现栈的入栈出栈操作 </p>
|
||||
|
||||
@ -1089,13 +1089,13 @@ comments: true
|
||||
使用数组实现栈时,我们可以将数组的尾部作为栈顶。如图 5-3 所示,入栈与出栈操作分别对应在数组尾部添加元素与删除元素,时间复杂度都为 $O(1)$ 。
|
||||
|
||||
=== "ArrayStack"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-3 基于数组实现栈的入栈出栈操作 </p>
|
||||
|
||||
|
Reference in New Issue
Block a user