auto commit

This commit is contained in:
CyC2018 2018-03-31 16:48:35 +08:00
parent 6071340e42
commit 3710e5ec13
3 changed files with 14 additions and 14 deletions

View File

@ -354,13 +354,13 @@ public class UF {
但是 union 操作代价却很高,需要将其中一个连通分量中的所有节点 id 值都修改为另一个节点的 id 值。
<div align="center"> <img src="../pics//75bb1eca-25a4-4f0b-b8e3-1bbe15c176cf.png" width="350"/> </div><br>
<div align="center"> <img src="../pics//9764bf07-4840-486c-988f-334acefc3f49.png" width="300"/> </div><br>
```java
public int find(int p) {
public int find(int p) {
return id[p];
}
public void union(int p, int q) {
}
public void union(int p, int q) {
int pID = find(p);
int qID = find(q);
@ -368,7 +368,7 @@ public class UF {
for (int i = 0; i < id.length; i++) {
if (id[i] == pID) id[i] = qID;
}
}
}
```
## quick-union
@ -377,7 +377,7 @@ public class UF {
但是 find 操作开销很大,因为同一个连通分量的节点 id 值不同id 值只是用来指向另一个节点。因此需要一直向上查找操作,直到找到最上层的节点。
<div align="center"> <img src="../pics//8d905dcf-19de-48ea-bfc2-762093ab5f54.png" width="350"/> </div><br>
<div align="center"> <img src="../pics//c5043b7e-6efe-4c55-b663-272e1097ed21.png" width="300"/> </div><br>
```java
public int find(int p) {
@ -563,12 +563,12 @@ public class Shell {
<div align="center"> <img src="../pics//8dfb4cc9-26da-45e7-b820-4576fa1cbb0e.png" width="350"/> </div><br>
<div align="center"> <img src="../pics//0c55e11c-d3ce-4cd8-b139-028aea6f40e3.png" width="450"/> </div><br>
### 1. 归并方法
归并方法将数组中两个已经排序的部分归并成一个。
<div align="center"> <img src="../pics//0c55e11c-d3ce-4cd8-b139-028aea6f40e3.png" width="450"/> </div><br>
```java
public class MergeSort {
private static Comparable[] aux;

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB