当前位置:网站首页>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
边栏推荐
- [the background color changes after clicking a line]
- 跨域CORS的情缘~
- Pavlov and hobbies
- 弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化
- JVM memory and memory overflow exceptions (personal summary)
- Differences between auto and decltype inference methods (learning notes)
- Necessity of selenium preloading cookies
- Requirements for SQL server to retrieve SQL and user information
- After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
- 双击.jar包无法运行解决方法
猜你喜欢
Double click The jar package cannot run the solution
Uniapp wechat sharing
Create a tabbar component under the components folder, which is public
‘EddiesObservations‘ object has no attribute ‘filled‘
Hongji micro classroom | cyclone RPA's "flexible digital employee" actuator
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器
Arithmetic and logical operations
弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化
deep learning object detection
随机推荐
CPT 104_TTL 09
catkin_package到底干了什么
Self incrementing sequence creation of MySQL
Add two pointers? (legal or illegal)
The main difference between pointer and reference
Relative reference and absolute reference of Excel
STL function library
Output string in reverse order
C语言——恶搞关机小程序
跨域CORS的情缘~
Frequently asked interview questions - 1 (non technical)
Excel sets row and column colors according to cell contents
Vscode settings JSON configuration
OSI层常用协议
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
五一劳动节期间什么理财产品会有收益?
Solve the problem of JS calculation accuracy
IPI interrupt
solidity合约DOS攻击
Camera imaging + homography transformation + camera calibration + stereo correction