知识卡片
BFS队列只含相邻两层
BFS 用先进先出队列维护当前搜索前沿;处理距离 k 的顶点时,新发现的顶点排在后面,距离为 k+1。因此队列中只会有相邻两层的部分顶点,而不会乱序跳到更远层。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第20章 基本图算法 · 查看原书依据
Instead, it uses a single first-in, first-out queue (see Section 10.1.3) containing some vertices at a distance k, possibly followed by some vertices at distance k + 1. The queue, therefore, contains portions of two consecutive waves at any time.
参考来源
- 位置:《算法导论(第4版)》第20章《基本图算法》(OEBPS/chapter020.xhtml,文本字符[10000,15000))。
- 结论依据:原文说明单个FIFO队列中最多包含相邻两层的顶点。
- 原始内容:Instead, it uses a single first-in, first-out queue (see Section 10.1.3 ) containing some vertices at a distance k , possibly followed by some vertices at distance k + 1. The queue, therefore, contains portions of two consecutive waves at any time.