Lecture 09: Practice Problems

1. Bipartite Checking

Can BFS be used to check if a graph is Bipartite (2-colorable)?

Show Answer

Yes.

Run BFS. Color layers alternately (Layer 0=Red, Layer 1=Blue...). If you find an edge between two nodes of the same color, it is not bipartite.

2. Shortest Path in Weighted Graph?

Does BFS find the shortest path in a weighted graph (even positive weights)?

Show Answer

No.

BFS only counts # of edges. It treats edge weight 100 same as edge weight 1.