Q. What is the main advantage of using BFS for searching in a graph?
A.
It uses less memory than DFS
B.
It guarantees the shortest path in unweighted graphs
C.
It is easier to implement
D.
It can handle cycles better than DFS
Solution
The main advantage of BFS is that it guarantees the shortest path in unweighted graphs by exploring all nodes at the present depth before moving deeper.
Correct Answer:
B
— It guarantees the shortest path in unweighted graphs
Q. What is the primary use of Breadth-First Search (BFS) in graph traversal?
A.
Finding the shortest path in an unweighted graph
B.
Finding connected components in a graph
C.
Sorting the nodes of a graph
D.
Detecting cycles in a graph
Solution
BFS is primarily used for finding the shortest path in an unweighted graph because it explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
A
— Finding the shortest path in an unweighted graph