Breadth First Search

1. Which of the following are applications of BFS?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

2. Imagine a 4×44 \times 4 grid (assume 1-based indexing) where the hero stands in cell (2,3)(2,3) and the villain is in cell (3,1)(3,1). 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?

Explanation

Explanation

Explanation

Explanation

3. In BFS, why is a vertex marked as visited when it is first discovered?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

4. What is the main difference between BFS and DFS in terms of the data structure used to manage the next vertex to process?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

5. Consider an unweighted graph. BFS starts at vertex ss and first reaches vertex vv after traversing 4 edges. What can be concluded?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

6. Which statement about BFS on a disconnected graph is correct?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

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:
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

8. Suppose BFS is performed on a graph using an adjacency list. Which operation contributes to the O(V+E)O(|V| + |E|) time complexity?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

9. Consider an undirected graph with source vertex ss. During BFS, vertex xx is discovered from vertex yy. If the BFS distance of yy from ss is kk, what distance is assigned to xx when xx is first discovered?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation