Skip to content

Commit

Permalink
feat(blog): update imgs
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyFBB committed Mar 4, 2024
1 parent 9cd8b55 commit b277259
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/DataStructure/Collection-of-common-algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ var hasCycle = function (head) {
[leetcode](https://leetcode-cn.com/problems/linked-list-cycle-ii/)

分析 1:快慢指针法。和上一题的方法一样,从链表头开始,快指针每次走两步,慢指针每次走一步。
![](/image/linked_list_sycle.png)
![](/blog/imgs/algorithm/linked_list_sycle.png)
D:头节点到入环点的距离
S1:从入环点到首次相遇点的距离
S2:从首次相遇点到入环点的距离
Expand Down
16 changes: 8 additions & 8 deletions docs/DataStructure/Graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ order: 7

在图中,有**无向图****有向图**之分,如果边有方向的话,就是有向图,反之则为无向图。

<div style="margin: auto;width:500px;">![无向图](/image/graph/first.png)</div>
![无向图](/blog/imgs/graph/first.png)

<div style="margin: auto;width:500px;">![无向图](/image/graph/second.png)</div>
![无向图](/blog/imgs/graph/second.png)

在无向图中,有度的概念,表示为一个顶点有多少条边。在有向图中,会把度分为**入度****出度**。入度表示有多少边指向这个顶点;出度表示有多少条边是以这个顶点为起点指向其他顶点。

还有一种图,叫做**带权图**,在带权图中每条边都有一个权重。

<div style="margin: auto;width:500px;">![无向图](/image/graph/three.png)</div>
![无向图](/blog/imgs/graph/three.png)

#### 存储方法

Expand All @@ -37,15 +37,15 @@ order: 7
图的最直观一种存储方式就是邻接矩阵。
邻接矩阵的底层是一个二维数组。对于无向图来说,如果顶点 i 和顶点 j 之间有边,就把 A[i][j]和 A[j][i]标记为 1;对于有向图来说,如果顶点 i 到顶点 j 之间,有一条箭头从顶点 i 指向顶点 j 的边,就把 A[i][j]标记为 1;对于带权图来说,数组中对应的存储相应的权重。

<div style="margin: auto;width:500px;">![无向图](/image/graph/array.png)</div>
![无向图](/blog/imgs/graph/array.png)

虽然这种存储方式简单、直观,但是比较浪费存储空间。尤其是对于无向图来说,A[i][j]为 1 的话,那么 A[j][i]也为 1。实际上,只需要存储一个就行了,等用于浪费了一般的存储空间。

##### 邻接表存储方法

在表示上,邻接表看起来有点像散列表。每个顶点,都对应了一条链表,链表中存储的是这个顶点与相连接的其他顶点。

<div style="margin: auto;width:500px;">![邻接表](/image/graph/list.png)</div>
![邻接表](/blog/imgs/graph/list.png)

### 构建图

Expand Down Expand Up @@ -94,7 +94,7 @@ class Graph {

这一段代码就已经将图类创建好了,如图:

<div style="margin: auto;width:500px;">![邻接表](/image/graph/search.png)</div>
![邻接表](/blog/imgs/graph/search.png)

为了直观的将邻接表展示出来,我们为 Graph 添加 toString 方法,能够展示出与每个顶点连接的其他的顶点。

Expand Down Expand Up @@ -156,7 +156,7 @@ __initializeColor() {

针对于上图,以'A'做为第一个访问顶点,它的访问顺序就是下图所展示的:

<div style="margin: auto;width:500px;">![示意图](/image/graph/bfs.png)</div>
![示意图](/blog/imgs/graph/bfs.png)

代码实现:

Expand Down Expand Up @@ -190,7 +190,7 @@ bfs(v, cb) {

针对于上图,以'A'做为第一个访问顶点,它的访问顺序就是下图所展示的:

<div style="margin: auto;width:500px;">![示意图](/image/graph/dfs.png)</div>
![示意图](/blog/imgs/graph/dfs.png)

代码实现:

Expand Down
2 changes: 1 addition & 1 deletion docs/DataStructure/LinkedList-problem-solving-ideas.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ var hasCycle = function (head) {
[leetcode](https://leetcode-cn.com/problems/linked-list-cycle-ii/)

分析 1:快慢指针法。和上一题的方法一样,从链表头开始,快指针每次走两步,慢指针每次走一步。
![](/image/linked_list_sycle.png)
![](/blog/imgs/algorithm/linked_list_sycle.png)
D:头节点到入环点的距离
S1:从入环点到首次相遇点的距离
S2:从首次相遇点到入环点的距离
Expand Down
10 changes: 5 additions & 5 deletions docs/DataStructure/NodeTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ order: 6
- 高度(height):节点到叶子节点的最长路径
- 深度(depth):根节点到这个节点所经历的边的个数
- 层(level):节点的深度+1
<div style="margin: auto">![普通二叉树](/image/tree/tree_height.png)</div>
![普通二叉树](/blog/imgs/tree/tree_height.png)

## 二叉树

在上面我们提到,二叉树就是每个节点最多含有两个子树。

<div style="margin: auto">![普通二叉树](/image/tree/binary_tree.png)</div>
![普通二叉树](/blog/imgs/tree/binary_tree.png)

### 关于递归

Expand Down Expand Up @@ -89,14 +89,14 @@ function traverse(root) {
这是一种基于指针或者引用的二叉链式存储法。这是一种常用的方式。
每个节点有三个字段,其中一个存储数据,另外两个是指向左右子节点的指针。

<div style="margin: auto">![普通二叉树](/image/tree/tree_linked.png)</div>
![普通二叉树](/blog/imgs/tree/tree_linked.png)

##### 顺序存储法

这是一种基于数组的顺序存储法。
我们把根节点存储在下标 i = 1 的位置,那左子节点存储在下标 2 \* i = 2 的位置,右子节点存储在 2 \* i + 1 = 3 的位置,以此类推。

<div style="margin: auto">![普通二叉树](/image/tree/tree_array.png)</div>
![普通二叉树](/blog/imgs/tree/tree_array.png)

所以某棵二叉树是一棵完全二叉树的时候,用数组存储是最节省内存的一种方式。

Expand Down Expand Up @@ -184,7 +184,7 @@ function levelOrder() {
- 其左子树(left subtree)下的每个后代节点(descendant node)的值都小于节点 n 的值;
- 其右子树(right subtree)下的每个后代节点的值都大于节点 n 的值。

<div style="margin: auto">![普通二叉树](/image/tree/binary_search_tree.png)</div>
![普通二叉树](/blog/imgs/tree/binary_search_tree.png)

#### 二叉查找树的构建

Expand Down
2 changes: 1 addition & 1 deletion docs/Engineering/Pnpm-package-management-that-I-know.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ order: 0

能够发现,这次是`base64-js@ 1.5.1`被提取到了根目录下的 node_modules 下,buffer 的 base64-js 能够和它兼容,所以 buffer 的 node_modules 下不再存在依赖,然而 bops 依赖的 base64-js 不兼容,所以会挂在自身的 node_modules 下

<div class="quote"> 💡 子依赖项的依赖不兼容的情况下,底层会通过[localeCompare](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)的方法对依赖进行一个排序,字典序靠前的 npm 包的**底层依赖**会优先被提取出来,放到根目录下的 node_modules 中,之后如果发现不兼容的依赖,则继续采用 npm 2 的处理方式,都会放在自身的 node_modules 下</div>
<div class="quote"> 💡 子依赖项的依赖不兼容的情况下,底层会通过 <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare">localeCompare</a> 的方法对依赖进行一个排序,字典序靠前的 npm 包的**底层依赖**会优先被提取出来,放到根目录下的 node_modules 中,之后如果发现不兼容的依赖,则继续采用 npm 2 的处理方式,都会放在自身的 node_modules 下</div>

❓ 通过上面这几个例子,能够发现 npm3 在解决了一些问题的同时,也带来新的问题。

Expand Down
Binary file added public/imgs/algorithm/linked_list_sycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/array.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/bfs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/dfs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/first.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/second.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/graph/three.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/binary_search_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/binary_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/gragh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/tree_array.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/tree_height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/imgs/tree/tree_linked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b277259

Please sign in to comment.