@@ -25,17 +25,17 @@ permalink: /pages/5a9bff/
2525
2626数组元素的访问是以行或列索引的单一下标表示。
2727
28- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320115836.png )
28+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320115836.png )
2929
3030在上面的例子中,数组 a 中有 5 个元素。` 也就是说 ` ,a 的长度是 6 。我们可以使用 a[ 0] 来表示数组中的第一个元素。因此,a[ 0] = A 。类似地,a[ 1] = B,a[ 2] = C,依此类推。
3131
3232### 数组的插入
3333
34- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320115848.png )
34+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320115848.png )
3535
3636### 数组的删除
3737
38- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320115859.png )
38+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320115859.png )
3939
4040### 数组的特性
4141
@@ -55,7 +55,7 @@ permalink: /pages/5a9bff/
5555
5656下图是由 M 个行向量,N 个列向量组成的二维数组.
5757
58- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320152607.png )
58+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320152607.png )
5959
6060## 链表
6161
@@ -80,7 +80,7 @@ permalink: /pages/5a9bff/
8080
8181单链表中的每个结点不仅包含数据值,还包含一个指针,指向其后继节点。通过这种方式,单链表将所有结点按顺序组织起来。
8282
83- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320174829.png )
83+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320174829.png )
8484
8585与数组不同,我们无法在常量时间内访问单链表中的随机元素。 如果我们想要获得第 i 个元素,我们必须从头结点逐个遍历。 我们按 ` 索引 ` 来 ` 访问元素 ` 平均要花费 ` O(N) ` 时间,其中 N 是链表的长度。
8686
@@ -90,15 +90,15 @@ permalink: /pages/5a9bff/
9090
9191(1)使用给定值初始化新结点 ` cur ` ;
9292
93- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320174908.png )
93+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320174908.png )
9494
9595(2)将 ` cur ` 的 ` next ` 字段链接到 ` prev ` 的下一个结点 ` next ` ;
9696
97- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320174919.png )
97+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320174919.png )
9898
9999(3)将 ` prev ` 中的 ` next ` 字段链接到 ` cur ` 。
100100
101- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320174932.png )
101+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320174932.png )
102102
103103与数组不同,我们不需要将所有元素移动到插入元素之后。因此,您可以在 ` O(1) ` 时间复杂度中将新结点插入到链表中,这非常高效。
104104
@@ -108,11 +108,11 @@ permalink: /pages/5a9bff/
108108
109109(1)找到 ` cur ` 的上一个结点 ` prev ` 及其下一个结点 ` next ` ;
110110
111- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320174953.png )
111+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320174953.png )
112112
113113(2)接下来链接 ` prev ` 到 ` cur ` 的下一个节点 ` next ` 。
114114
115- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320175006.png )
115+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320175006.png )
116116
117117在我们的第一步中,我们需要找出 ` prev ` 和 ` next ` 。使用 ` cur ` 的参考字段很容易找出 ` next ` ,但是,我们必须从头结点遍历链表,以找出 ` prev ` ,它的平均时间是 ` O(N) ` ,其中 ` N ` 是链表的长度。因此,删除结点的时间复杂度将是 ` O(N) ` 。
118118
@@ -124,7 +124,7 @@ permalink: /pages/5a9bff/
124124
125125单链表的访问是单向的,而双链表的访问是双向的。显然,双链表比单链表操作更灵活,但是空间开销也更大。
126126
127- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320181150.png )
127+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320181150.png )
128128
129129双链表以类似的方式工作,但` 还有一个引用字段 ` ,称为` “prev” ` 字段。有了这个额外的字段,您就能够知道当前结点的前一个结点。
130130
@@ -134,15 +134,15 @@ permalink: /pages/5a9bff/
134134
135135(1)使用给定值初始化新结点 ` cur ` ;
136136
137- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320181208.png )
137+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320181208.png )
138138
139139(2)链接 ` cur ` 与 ` prev ` 和 ` next ` ,其中 ` next ` 是 ` prev ` 原始的下一个节点;
140140
141- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320181303.png )
141+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320181303.png )
142142
143143(3)用 ` cur ` 重新链接 ` prev ` 和 ` next ` 。
144144
145- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220320181504.png )
145+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220320181504.png )
146146
147147与单链表类似,添加操作的时间和空间复杂度都是 ` O(1) ` 。
148148
@@ -163,11 +163,11 @@ permalink: /pages/5a9bff/
163163- 单链表的最后一个结点的后继指针 ` next ` 指向空地址。
164164- 循环链表的最后一个结点的后继指针 ` next ` 指向第一个节点(如果有头节点,就指向头节点)。
165165
166- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220322190534.png )
166+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220322190534.png )
167167
168168#### 循环双链表
169169
170- ![ img] ( https://raw.githubusercontent.com/dunwu/images/dev /snap/20220322190423.png )
170+ ![ img] ( https://raw.githubusercontent.com/dunwu/images/master /snap/20220322190423.png )
171171
172172## 数组 vs. 链表
173173
0 commit comments