auto commit
This commit is contained in:
parent
286d54fb91
commit
26e0cffc70
|
@ -315,11 +315,11 @@ public class Queue<Item> {
|
|||
|
||||
用于解决动态连通性问题,能动态连接两个点,并且判断两个点是否连通。
|
||||
|
||||
<div align="center"> <img src="../pics//dc752c5b-bb59-4616-bf9c-21276690a24d.png" width="400"/> </div><br>
|
||||
<div align="center"> <img src="../pics//9d0a637c-6a8f-4f5a-99b9-fdcfa26793ff.png" width="400"/> </div><br>
|
||||
|
||||
|
||||
| 方法 | 描述 |
|
||||
| ---: | :--- |
|
||||
| :---: | :---: |
|
||||
| UF(int N) | 构造一个大小为 N 的并查集 |
|
||||
| void union(int p, int q) | 连接 p 和 q 节点 |
|
||||
| int find(int p) | 查找 p 所在的连通分量 |
|
||||
|
@ -399,7 +399,7 @@ public void union(int p, int q) {
|
|||
|
||||
理论研究证明,加权 quick-union 算法构造的树深度最多不超过 logN。
|
||||
|
||||
<div align="center"> <img src="../pics//095720ee-84b3-42ff-af71-70ceb6a2f4a3.png" width="400"/> </div><br>
|
||||
<div align="center"> <img src="../pics//8229e8e7-a183-4d29-94e6-e8d8537c6ce5.png" width="200"/> </div><br>
|
||||
|
||||
```java
|
||||
public class WeightedQuickUnionUF {
|
||||
|
|
BIN
pics/8229e8e7-a183-4d29-94e6-e8d8537c6ce5.png
Normal file
BIN
pics/8229e8e7-a183-4d29-94e6-e8d8537c6ce5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
pics/9d0a637c-6a8f-4f5a-99b9-fdcfa26793ff.png
Normal file
BIN
pics/9d0a637c-6a8f-4f5a-99b9-fdcfa26793ff.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user