1.

What would thetime complexity to check if an undirected graph with V vertices and E edges is Bipartite or not given its adjacency matrix?(a) O(E*E)(b) O(V*V)(c) O(E)(d) O(V)The origin of the question is Undirected Graph in portion Graph of Data Structures & Algorithms II have been asked this question during an interview for a job.

Answer»

Correct answer is (B) O(V*V)

The best I can explain: A graph can be checked for being Bipartite by seeing if it is 2-colorable or not, which can be obtained with the HELP of BFS.



Discussion

No Comment Found

Related InterviewSolutions