diff --git a/chapter_array_and_linkedlist/array/index.html b/chapter_array_and_linkedlist/array/index.html index 2fcce81e7..cc07d48b5 100644 --- a/chapter_array_and_linkedlist/array/index.html +++ b/chapter_array_and_linkedlist/array/index.html @@ -3763,8 +3763,8 @@
可视化运行 -

-全屏观看 >

+

+
全屏观看 >

2.   访问元素

数组元素被存储在连续的内存空间中,这意味着计算数组元素的内存地址非常容易。给定数组内存地址(首元素内存地址)和某个元素的索引,我们可以使用图 4-2 所示的公式计算得到该元素的内存地址,从而直接访问该元素。

@@ -3911,8 +3911,8 @@
可视化运行 -

-全屏观看 >

+

+
全屏观看 >

3.   插入元素

数组元素在内存中是“紧挨着的”,它们之间没有空间再存放任何数据。如图 4-3 所示,如果想在数组中间插入一个元素,则需要将该元素之后的所有元素都向后移动一位,之后再把元素赋值给该索引。

@@ -4069,8 +4069,8 @@
可视化运行 -

-全屏观看 >

+

+
全屏观看 >

4.   删除元素

同理,如图 4-4 所示,若想删除索引 \(i\) 处的元素,则需要把索引 \(i\) 之后的元素都向前移动一位。

@@ -4204,8 +4204,8 @@
可视化运行 -

-全屏观看 >

+

+
全屏观看 >

总的来看,数组的插入与删除操作有以下缺点。

diff --git a/en/chapter_data_structure/index.html b/en/chapter_data_structure/index.html index f73c3a4ec..f2f369382 100644 --- a/en/chapter_data_structure/index.html +++ b/en/chapter_data_structure/index.html @@ -1089,6 +1089,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_data_structure/number_encoding/index.html b/en/chapter_data_structure/number_encoding/index.html index 34bad1756..6cd9b56fd 100644 --- a/en/chapter_data_structure/number_encoding/index.html +++ b/en/chapter_data_structure/number_encoding/index.html @@ -1147,6 +1147,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_data_structure/summary/index.html b/en/chapter_data_structure/summary/index.html index 33c3a5b7e..e9095836c 100644 --- a/en/chapter_data_structure/summary/index.html +++ b/en/chapter_data_structure/summary/index.html @@ -1147,6 +1147,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_introduction/algorithms_are_everywhere/index.html b/en/chapter_introduction/algorithms_are_everywhere/index.html index 024a87bc2..26c8c4866 100644 --- a/en/chapter_introduction/algorithms_are_everywhere/index.html +++ b/en/chapter_introduction/algorithms_are_everywhere/index.html @@ -1099,6 +1099,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_introduction/index.html b/en/chapter_introduction/index.html index adea7e225..d89e51716 100644 --- a/en/chapter_introduction/index.html +++ b/en/chapter_introduction/index.html @@ -1089,6 +1089,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_introduction/summary/index.html b/en/chapter_introduction/summary/index.html index b53274119..a5afb12b1 100644 --- a/en/chapter_introduction/summary/index.html +++ b/en/chapter_introduction/summary/index.html @@ -1099,6 +1099,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_introduction/what_is_dsa/index.html b/en/chapter_introduction/what_is_dsa/index.html index f89ae8a81..d26992f4a 100644 --- a/en/chapter_introduction/what_is_dsa/index.html +++ b/en/chapter_introduction/what_is_dsa/index.html @@ -1156,6 +1156,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_preface/about_the_book/index.html b/en/chapter_preface/about_the_book/index.html index b2987868b..5c441ff40 100644 --- a/en/chapter_preface/about_the_book/index.html +++ b/en/chapter_preface/about_the_book/index.html @@ -1156,6 +1156,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_preface/index.html b/en/chapter_preface/index.html index 65a433636..ebc786aca 100644 --- a/en/chapter_preface/index.html +++ b/en/chapter_preface/index.html @@ -1087,6 +1087,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_preface/suggestions/index.html b/en/chapter_preface/suggestions/index.html index 48b72a231..0412fde5c 100644 --- a/en/chapter_preface/suggestions/index.html +++ b/en/chapter_preface/suggestions/index.html @@ -1174,6 +1174,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_preface/summary/index.html b/en/chapter_preface/summary/index.html index b3d173cd7..f5cff3441 100644 --- a/en/chapter_preface/summary/index.html +++ b/en/chapter_preface/summary/index.html @@ -1099,6 +1099,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + + diff --git a/en/chapter_stack_and_queue/deque/index.html b/en/chapter_stack_and_queue/deque/index.html index 24dd384bc..551a46bd0 100644 --- a/en/chapter_stack_and_queue/deque/index.html +++ b/en/chapter_stack_and_queue/deque/index.html @@ -15,6 +15,10 @@ + + + + @@ -22,7 +26,7 @@ - Double-Ended Queue - Hello Algo + 5.3 Double-ended Queue - Hello Algo @@ -87,7 +91,7 @@
    - + Skip to content @@ -122,7 +126,7 @@
    - Double-Ended Queue + 5.3 Double-ended Queue
    @@ -1083,6 +1087,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + +
  • + + +
    @@ -1110,37 +1361,37 @@ @@ -1103,6 +1263,23 @@ + + + @@ -1137,15 +1314,22 @@ -

    Stack and Queue

    +

    Chapter 5.   Stack and Queue

    -

    Stack and Queue

    +

    Stack and Queue

    Abstract

    Stacks are like stacking cats, while queues are like cats lining up.

    They respectively represent the logical relationships of Last-In-First-Out (LIFO) and First-In-First-Out (FIFO).

    +

    Chapter Contents

    + @@ -1164,13 +1348,110 @@ aria-label="Footer" + + + + + + + + + + + +
    Feel free to drop your insights, questions or suggestions
    + + + + + + @@ -1192,6 +1473,44 @@ aria-label="Footer"