1.

In BFS, how many times a node is visited?(a) Once(b) Twice(c) Equivalent to number of indegree of the node(d) ThriceThis question was posed to me during an interview.This key question is from Breadth First Search topic in section Graph Search of Data Structures & Algorithms II

Answer»

The correct answer is (c) Equivalent to number of INDEGREE of the node

Easiest EXPLANATION - In BREADTH FIRST Search, we have to see whether the node is visited or not by it’s ancestor. If it is visited, we won’t let it enter it in the queue.



Discussion

No Comment Found

Related InterviewSolutions