Questions: Breadth-First Search: Implementation and Applications

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A graph has vertices A, B, C, D where A connects to B and C, B connects to D, and C connects to D. Starting BFS from A, you want the shortest path to D. Which sequence does BFS guarantee?

AA → B → D, because BFS explores the first neighbor it finds
BA → C → D, because alphabetical ordering determines BFS priority
CEither A → B → D or A → C → D — both have length 2, and BFS guarantees both are shortest
DA → B → C → D, because BFS visits all vertices before backtracking
Question 2 Multiple Choice

You are testing whether a graph is bipartite using BFS. You color the source vertex red, its neighbors blue, their neighbors red, and so on. What condition indicates the graph is NOT bipartite?

ABFS reaches a vertex that has already been visited
BA vertex is about to be colored, but its already-colored neighbor has the same color
CBFS terminates before visiting all vertices
DA vertex has more neighbors of one color than the other
Question 3 True / False

BFS can find all connected components of an undirected graph by repeatedly starting BFS from any unvisited vertex until all vertices have been visited.

TTrue
FFalse
Question 4 True / False

In a weighted graph where edge weights represent distances, BFS finds the shortest path between any two vertices.

TTrue
FFalse
Question 5 Short Answer

Why does BFS guarantee that the first time it reaches a vertex, it has found the shortest path to that vertex in an unweighted graph?

Think about your answer, then reveal below.