Breadth First Search
1. Which of the following are applications of BFS?
2. Imagine a grid (assume 1-based indexing) where the hero stands in cell and the villain is in cell . Assuming the hero can move only up, down, left, or right to an immediately adjacent cell and cannot move outside the grid, how many steps will it take for the hero to reach the stationary villain?
3. In BFS, why is a vertex marked as visited when it is first discovered?
4. What is the main difference between BFS and DFS in terms of the data structure used to manage the next vertex to process?
5. Consider an unweighted graph. BFS starts at vertex and first reaches vertex after traversing 4 edges. What can be concluded?
6. Which statement about BFS on a disconnected graph is correct?
7. In an unweighted graph, BFS is commonly preferred over DFS when the goal is to find the shortest path from a source to a target because BFS:
8. Suppose BFS is performed on a graph using an adjacency list. Which operation contributes to the time complexity?
9. Consider an undirected graph with source vertex . During BFS, vertex is discovered from vertex . If the BFS distance of from is , what distance is assigned to when is first discovered?