当前位置:网站首页>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
边栏推荐
- 使用宝塔+xdebug+vscode远程调试代码
- Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
- Use of ES6 array
- 转置卷积(Transposed Convolution)
- Pavlov and hobbies
- What financial products will benefit during May Day?
- Establish excel bookkeeping book through setting context menu
- windows连接mysql出现ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)
- (十一)vscode代码格式化配置
- ‘EddiesObservations‘ object has no attribute ‘filled‘
猜你喜欢
Create cells through JS (while loop)
Various situations of data / component binding
‘EddiesObservations‘ object has no attribute ‘filled‘
C, class library
Data mining -- understanding data
Radar equipment (greedy)
Use of qwbengneview and qwebchannel.
Arithmetic and logical operations
Double click The jar package cannot run the solution
selenium預先加載cookie的必要性
随机推荐
[untitled] Notepad content writing area
Note: unordered_ Understanding and use of map
相机成像+单应性变换+相机标定+立体校正
Edit, cancel, pull up menu
Intel SGX preliminary learning and understanding notes (continuously updated)
Basic knowledge of redis
弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化
selenium预先加载cookie的必要性
C# ,类库
The address value indicated by the pointer and the value of the object indicated by the pointer (learning notes)
catkin_ What did package do
qt. qpa. plugin: Could not find the Qt platform plugin “xcb“ in ““
MySQL series - install MySQL 5.6.27 on Linux and solve common problems
双击.jar包无法运行解决方法
STD:: String implements split
Use of uniapp native plug-ins
Create cells through JS (while loop)
JVM memory and memory overflow exceptions (personal summary)
Three methods of list rendering
Branch and loop statements