Update numbering
This commit is contained in:
parent
416a722594
commit
ae53c59183
@ -2,7 +2,7 @@
|
||||
comments: true
|
||||
---
|
||||
|
||||
# 图的遍历
|
||||
# 9.3. 图的遍历
|
||||
|
||||
!!! note "图与树的关系"
|
||||
|
||||
@ -12,7 +12,7 @@ comments: true
|
||||
|
||||
类似地,图的遍历方式也分为两种,即「广度优先遍历 Breadth-First Traversal」和「深度优先遍历 Depth-First Travsersal」,也称「广度优先搜索 Breadth-First Search」和「深度优先搜索 Depth-First Search」,简称为 BFS 和 DFS 。
|
||||
|
||||
## 广度优先遍历
|
||||
## 9.3.1. 广度优先遍历
|
||||
|
||||
**广度优先遍历优是一种由近及远的遍历方式,从距离最近的顶点开始访问,并一层层向外扩张**。具体地,从某个顶点出发,先遍历该顶点的所有邻接顶点,随后遍历下个顶点的所有邻接顶点,以此类推……
|
||||
|
||||
@ -133,7 +133,7 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
|
||||
|
||||
**空间复杂度:** 列表 `res` ,哈希表 `visited` ,队列 `que` 中的顶点数量最多为 $|V|$ ,使用 $O(|V|)$ 空间。
|
||||
|
||||
## 深度优先遍历
|
||||
## 9.3.2. 深度优先遍历
|
||||
|
||||
**深度优先遍历是一种优先走到底、无路可走再回头的遍历方式**。具体地,从某个顶点出发,不断地访问当前结点的某个邻接顶点,直到走到尽头时回溯,再继续走到底 + 回溯,以此类推……直至所有顶点遍历完成时结束。
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user