Group 9
• Taminul Islam (181-15-11116)
• Rayhanur Rashid Nur (181-15-11069)
Breadth First Search
Definition
What is BFS?
Breadth-first search (BFS) is an algorithm for traversing or searching tree or
graph data structures. It starts at the tree root (or some arbitrary node of a
graph, sometimes referred to as a 'search key') and explores all of the neighbor
nodes at the present depth prior to moving on to the nodes at the next depth
level.
BFS Method
Method
1.The Breadth first search begins at a root node and
inspects all the neighboring nodes.
2.Then for each of those neighbor nodes in turn,
it inspects their neighbor nodes which were
unvisited, and so on.
Binary graph searching
Step-1: A breadth-first search (BFS) explores
nodes nearest the root before exploring nodes
further away.
Step- 2:For example, after searching A, then B,
then C, the search proceeds with D, E, F, G
Step-3: Node are explored in the order A B C D
E F G H I J K L M N O P Q.
Step-4:H will be found before K.
Let’s we will see how to work level order
searching
BFS in details
9
1
4
10
83
7
5
2
6
BFS
Queue
9
1
4
10
83
7
5
2
6
BFS
Queue
1
1
9
1
4
10
83
7
5
2
6
BFS
Queue
1
1
4 2
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2
4
2
3
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2
2
3
3
5 7 8
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8
5
7
8
3
10 9
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8
5
7
8
10 9
10
9
6
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8
7
8
10 9
10
9
6
6
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8
8
10 9
10
9
6
6
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8 10 9
10
9
6
6
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8 10 9
9
6
6
9
1
4
10
83
7
5
2
6
BFS
Queue
1 4 2 3 5 7 8 10 9 6
6
Final Answer
(BFS)
1 4 2 3 5 7 8 10 9 6
Applications
 Breadth first search can be used to solve games where a
series of choices result in either a winning or losing state.
For example: BFS can help a player determine a winning
sequence of moves for solving a Rubik’s cube.
 BFS is also used in the famous Dijkstra’s algorithm for computing
the shortest path in a graph and the Ford-Fulkerson algorithm for
computing the maximum​ flow in a flow network.
Example of a map that BFS can take and return the shortest paths
SHORTED
BFS is also used in Analyzing Network
Breadth First Search

Breadth First Search