mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-01 17:53:18 +08:00
build
This commit is contained in:
@@ -6,7 +6,7 @@ comments: true
|
||||
|
||||
在队列中,我们仅能在头部删除或在尾部添加元素。如图 5-7 所示,「双向队列 double-ended queue」提供了更高的灵活性,允许在头部和尾部执行元素的添加或删除操作。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-7 双向队列的操作 </p>
|
||||
|
||||
@@ -365,19 +365,19 @@ comments: true
|
||||
如图 5-8 所示,我们将双向链表的头节点和尾节点视为双向队列的队首和队尾,同时实现在两端添加和删除节点的功能。
|
||||
|
||||
=== "LinkedListDeque"
|
||||

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

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

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

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

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-8 基于链表实现双向队列的入队出队操作 </p>
|
||||
|
||||
@@ -2008,19 +2008,19 @@ comments: true
|
||||
如图 5-9 所示,与基于数组实现队列类似,我们也可以使用环形数组来实现双向队列。
|
||||
|
||||
=== "ArrayDeque"
|
||||

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

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

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

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

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-9 基于数组实现双向队列的入队出队操作 </p>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ icon: material/stack-overflow
|
||||
|
||||
<div class="center-table" markdown>
|
||||
|
||||
{ width="600" }
|
||||
{ class="cover-image" }
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ comments: true
|
||||
|
||||
如图 5-4 所示,我们将队列的头部称为“队首”,尾部称为“队尾”,将把元素加入队尾的操作称为“入队”,删除队首元素的操作称为“出队”。
|
||||
|
||||

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-4 队列的先入先出规则 </p>
|
||||
|
||||
@@ -325,13 +325,13 @@ comments: true
|
||||
如图 5-5 所示,我们可以将链表的“头节点”和“尾节点”分别视为“队首”和“队尾”,规定队尾仅可添加节点,队首仅可删除节点。
|
||||
|
||||
=== "LinkedListQueue"
|
||||

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

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

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-5 基于链表实现队列的入队出队操作 </p>
|
||||
|
||||
@@ -1216,13 +1216,13 @@ comments: true
|
||||
可以看到,入队和出队操作都只需进行一次操作,时间复杂度均为 $O(1)$ 。
|
||||
|
||||
=== "ArrayQueue"
|
||||

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

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

|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 5-6 基于数组实现队列的入队出队操作 </p>
|
||||
|
||||
|
||||
@@ -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