当前位置:网站首页>Breadth first search topics (BFS)
Breadth first search topics (BFS)
2022-04-23 05:34:00 【Han Tiao】
Personal home page : A happy pig
Writing style : Simple and clear , Just dry goods
The field of writing : Blue bridge , Power button , Brush question skill
Support pigs : give the thumbs-up + Collection + Focus on
BFS
1、 Search down layer by layer in hierarchical order ( But usually you don't have to search all the situations to get the answer )
2、 Hierarchy traversal requires queue
Templates :
void BFS(int s)
{
Deque<Integer> que=new LinkedList<>();
que.offer(s);
while(!q.empty())
{
1、 Take out the team leader element top;
2、 Visit the team leader element top;
3、 Take the first element out of the team ;
4、 take top All nodes that have not been visited in the next layer of nodes join the queue , And set it to be accessed ;
}
}
The second step of accessing the first element of the team can be many complex operations , Different for specific problems
The fourth step requires a visted Array to identify whether a node has been accessed
BFS There are many applications , For example, traversing a binary tree , Ergodic graph , Find the best path to the maze , There are even some abstract problems , Let's brush the questions in practice
Related topics
1、 Find in the matrix “ block “ The number of (BFS)
2、 Blue Bridge Cup 2019 Real exercise in ——4、 maze (JavaA Group )
3、 Blue Bridge Cup 2017 The eighth real topic in - Frog jumping cup
4、 Blue Bridge Cup 2020 Real exercise in ——4、 Seven segment code (JavaA Group )
If this article is helpful to my friends , I hope the following points can be supported ~ Thank you !

版权声明
本文为[Han Tiao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220534299893.html
边栏推荐
- Data mining -- understanding data
- Note: unordered_ Understanding and use of map
- After NPM was upgraded, there was a lot of panic
- Box collapse and margin collapse
- MySQL series - install MySQL 5.6.27 on Linux and solve common problems
- Rog attack
- Getting started with varnish
- World and personal development
- On the use of constant pointer and pointer constant -- exercise (record)
- Parsing of string class intern() method
猜你喜欢
![[triangle Yang Hui triangle printing odd even cycle JS for break cycle]](/img/9a/6cdc00e6056a1a47d2fbb8b9a8e975.png)
[triangle Yang Hui triangle printing odd even cycle JS for break cycle]

‘EddiesObservations‘ object has no attribute ‘filled‘

(十一)vscode代码格式化配置

Fast application fuzzy search

Arithmetic and logical operations

Data mining -- understanding data
![[untitled] Notepad content writing area](/img/0a/4a3636025c3e0441f45c99e3c67b67.png)
[untitled] Notepad content writing area

Create a tabbar component under the components folder, which is public
Basic knowledge of redis

弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器
随机推荐
CORS and proxy (づ  ̄ 3  ̄) in egg ~ the process of stepping on the pit and filling the pit ~ tot~
catkin_package到底干了什么
Ehcache Memcache redis three caches
橙单微服务之批量导入
Cross platform packaging of QT packaging program
Executable program execution process
[untitled] Notepad content writing area
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
Pavlov and hobbies
solidity合约DOS攻击
JS time format conversion
Camera imaging + homography transformation + camera calibration + stereo correction
Cmake basic tutorial (39) pkgconfig
The QT debug version runs normally and the release version runs crash
Xiuxian real world and game world
Uniapp hot update with progress bar
catkin_ What did package do
Various situations of data / component binding
JVM memory and memory overflow exceptions (personal summary)
双击.jar包无法运行解决方法