refactor: Replace 结点 with 节点 (#452)

* Replace 结点 with 节点
Update the footnotes in the figures

* Update mindmap

* Reduce the size of the mindmap.png
This commit is contained in:
Yudong Jin
2023-04-09 04:32:17 +08:00
committed by GitHub
parent 3f4e32b2b0
commit 1c8b7ef559
395 changed files with 2056 additions and 2056 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -289,11 +289,11 @@
### 基于双向链表的实现
回忆上节内容,由于可以方便地删除链表头点(对应出队操作),以及在链表尾点后添加新点(对应入队操作),因此我们使用普通单向链表来实现队列。
回忆上节内容,由于可以方便地删除链表头点(对应出队操作),以及在链表尾点后添加新点(对应入队操作),因此我们使用普通单向链表来实现队列。
而双向队列的头部和尾部都可以执行入队与出队操作,换言之,双向队列的操作是“首尾对称”的,也需要实现另一个对称方向的操作。因此,双向队列需要使用「双向链表」来实现。
我们将双向链表的头点和尾点分别看作双向队列的队首和队尾,并且实现在两端都能添加与删除点。
我们将双向链表的头点和尾点分别看作双向队列的队首和队尾,并且实现在两端都能添加与删除点。
=== "LinkedListDeque"
![基于链表实现双向队列的入队出队操作](deque.assets/linkedlist_deque.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -258,7 +258,7 @@
### 基于链表的实现
我们将链表的「头点」和「尾点」分别看作是队首和队尾,并规定队尾只可添加点,队首只可删除点。
我们将链表的「头点」和「尾点」分别看作是队首和队尾,并规定队尾只可添加点,队首只可删除点。
=== "LinkedListQueue"
![基于链表实现队列的入队出队操作](queue.assets/linkedlist_queue.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -258,9 +258,9 @@
### 基于链表的实现
使用「链表」实现栈时,将链表的头点看作栈顶,将尾点看作栈底。
使用「链表」实现栈时,将链表的头点看作栈顶,将尾点看作栈底。
对于入栈操作,将元素插入到链表头部即可,这种点添加方式被称为“头插法”。而对于出栈操作,则将头点从链表中删除即可。
对于入栈操作,将元素插入到链表头部即可,这种点添加方式被称为“头插法”。而对于出栈操作,则将头点从链表中删除即可。
=== "LinkedListStack"
![基于链表实现栈的入栈出栈操作](stack.assets/linkedlist_stack.png)
@@ -418,7 +418,7 @@
在数组(列表)实现中,入栈与出栈操作都是在预先分配好的连续内存中操作,具有很好的缓存本地性,效率很好。然而,如果入栈时超出数组容量,则会触发扩容机制,那么该次入栈操作的时间复杂度为 $O(n)$ 。
在链表实现中,链表的扩容非常灵活,不存在上述数组扩容时变慢的问题。然而,入栈操作需要初始化点对象并修改指针,因而效率不如数组。进一步地思考,如果入栈元素不是 `int` 而是点对象,那么就可以省去初始化步骤,从而提升效率。
在链表实现中,链表的扩容非常灵活,不存在上述数组扩容时变慢的问题。然而,入栈操作需要初始化点对象并修改指针,因而效率不如数组。进一步地思考,如果入栈元素不是 `int` 而是点对象,那么就可以省去初始化步骤,从而提升效率。
综上所述,当入栈与出栈操作的元素是基本数据类型(例如 `int` , `double` )时,则结论如下:
@@ -429,7 +429,7 @@
在初始化列表时,系统会给列表分配“初始容量”,该容量可能超过我们的需求。并且扩容机制一般是按照特定倍率(比如 2 倍)进行扩容,扩容后的容量也可能超出我们的需求。因此,**数组实现栈会造成一定的空间浪费**。
当然,由于点需要额外存储指针,因此 **链表点比数组元素占用更大**
当然,由于点需要额外存储指针,因此 **链表点比数组元素占用更大**
综上,我们不能简单地确定哪种实现更加省内存,需要 case-by-case 地分析。

View File

@@ -2,6 +2,6 @@
- 栈是一种遵循先入后出的数据结构,可以使用数组或链表实现。
- 在时间效率方面,栈的数组实现具有更好的平均效率,但扩容时会导致单次入栈操作的时间复杂度劣化至 $O(n)$ 。相对地,栈的链表实现具有更加稳定的效率表现。
- 在空间效率方面,栈的数组实现会造成一定空间浪费,然而链表点比数组元素占用内存更大。
- 在空间效率方面,栈的数组实现会造成一定空间浪费,然而链表点比数组元素占用内存更大。
- 队列是一种遵循先入先出的数据结构,可以使用数组或链表实现。对于两种实现的时间效率与空间效率对比,与上述栈的结论相同。
- 双向队列的两端都可以添加与删除元素。