mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-25 03:08:54 +08:00
build
This commit is contained in:
@ -330,13 +330,13 @@ comments: true
|
||||
如图 5-2 所示,对于入栈操作,我们只需将元素插入链表头部,这种节点插入方法被称为“头插法”。而对于出栈操作,只需将头节点从链表中删除即可。
|
||||
|
||||
=== "LinkedListStack"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-2 基于链表实现栈的入栈出栈操作 </p>
|
||||
|
||||
@ -1094,13 +1094,13 @@ comments: true
|
||||
使用数组实现栈时,我们可以将数组的尾部作为栈顶。如图 5-3 所示,入栈与出栈操作分别对应在数组尾部添加元素与删除元素,时间复杂度都为 $O(1)$ 。
|
||||
|
||||
=== "ArrayStack"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "push()"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "pop()"
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-3 基于数组实现栈的入栈出栈操作 </p>
|
||||
|
||||
|
Reference in New Issue
Block a user