1.

Time Complexity of Breadth First Search is? (V – number of vertices, E – number of edges)(a) O(V + E)(b) O(V)(c) O(E)(d) O(V*E)I got this question during an interview.My question is from Breadth First Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

Correct answer is (a) O(V + E)

Best explanation: The Breadth FIRST Search EXPLORES every NODE once and every EDGE once (in worst case), so it’s time COMPLEXITY is O(V + E).



Discussion

No Comment Found

Related InterviewSolutions