Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A graph is said to be bipartite if all its vertices can be partitioned into two

ID: 3168426 • Letter: A

Question

A graph is said to be bipartite if all its vertices can be partitioned into two disjoint subsetsX and Y so that every edge connects a vertex inx with a vertex in Y. (One can also say that a graph is bipartite if its vertices can be colored in two colors so that every edge has its vertices colored in different colors, such graphs are also called 2-colorable.) For example, graph (i) is bipartite while graph (ii) is not. ab Il a. Design a DFS-based algorithm for checking whether a graph is bipartite. b. Design a BFs-based algorithm for checking whether a graph is bipartite.

Explanation / Answer

a.DFS-based

b.BFS-based

1. Assign RED color to the source vertex (putting into set U).

2. Color all the neighbors with BLUE color (putting into set V).

3. Color all neighbor