Breadth / breadth-first search in the end is what the hell (animation solution algorithm for various versions of the code that implements attached)

Breadth / width first search the BFS (attachment animation Algorithms for all versions of code implementation)

Inside the video using a pseudo-code , is to give the reader a variety of languages to understand, I will give concrete realization of the link. Performance analysis and comparison of the depth-first search later.

BFS

The video "breadth / breadth-first search (BFS)" as the original video bloggers, if you feel ok speak clear, a point of concern, tap the link swipe amount of play, making easy, thank you.

BTree- two trees: breadth / breadth-first search (BFS)
URL: https: //www.bilibili.com/video/av96224366

Example "994 rotten orange":

994. rotten oranges breadth-first search example

BTree- two trees: 994 rotten oranges
URL: https: //www.bilibili.com/video/av96224669

Depth-first search

Depth-first search

URL: HTTPS: //www.bilibili.com/video/av97215609
BTree- two tree: depth-first search

1. code implementation

To save space, open-minded.
Links: code implementation

Introduction 2. BFS

2.1 breadth-first search is exactly what a

Here Insert Picture Description
Bored, I decided to pop a little.
Here Insert Picture Description

2.2 went to the hi (yi) smell (lian) music (meng) see (bi) performance analysis, as well as proof of linksHere Insert Picture DescriptionHere Insert Picture Description

Here Insert Picture Description

3. The implementation process

Step 3.1Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

3.2 implementation

Hong Kong really, animation does not smell?
Here Insert Picture Description

4 examples

The title comes from the leetcode " 994. The rotten orange " tort legislation deleted, URL: https: //leetcode-cn.com/problems/rotting-oranges/
example, "994 rotten orange" :

994. rotten oranges breadth-first search example

BTree- two trees: 994 rotten oranges
URL: https: //www.bilibili.com/video/av96224669

Here Insert Picture Description

4.1 Pseudocode

Here Insert Picture Description

4.2 Specific implementation steps

With the video, I feel like I do not need too much explanation, and there for how to think, how to think, how I should play with the idea after the code that I feel are more detailed, so here stole a lazy bar.

4.3 Analysis of the complexity of time and space complexity

Time complexity: O (m * n) space complexity: O (m * n)

4.4 specific code implementation

leetcode official answer: The official answer
URL: https: //leetcode-cn.com/problems/rotting-oranges/solution/fu-lan-de-ju-zi-by-leetcode-solution/

5 References

CSDN bloggers raphealguo Bowen " [algorithm] breadth entry / breadth-first search (BFS) " URL: https:? //Blog.csdn.net/raphealguo/article/details/7523411 depth_1-utm_source = distribute.pc_relevant.none- task & utm_source = distribute.pc_relevant.none-task

CSDN博主Chida15的博文《图的广度优先搜索(BFS)和深度优先搜索(DFS)算法解析》网址:https://blog.csdn.net/weixin_40953222/article/details/80544928?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

CSDN博主镇上村树的博文《深度优先搜索和广度优先搜索的区别》网址:
https://blog.csdn.net/realdonaldtrump/article/details/78002903

CSDN博主KLFTESPACE的博文《深度优先搜索和广度优先搜索的比较与分析》网址:
https://blog.csdn.net/KLFTESPACE/article/details/80145113

leetcode题目《994. 腐烂的橘子》侵权立删,网址:https://leetcode-cn.com/problems/rotting-oranges/

leetcode题目994. 腐烂的橘子的答案《l官方答案》,网址:https://leetcode-cn.com/problems/rotting-oranges/solution/fu-lan-de-ju-zi-by-leetcode-solution/

算法导论P340-349

数据结构与算法分析、C++语言描述

Released eight original articles · won praise 22 · views 1791

Guess you like

Origin blog.csdn.net/qq_45877524/article/details/104845320