1.

In Depth First Search, how many times a node is visited?(a) Once(b) Twice(c) Equivalent to number of indegree of the node(d) ThriceThis question was addressed to me during an interview for a job.My doubt is from Depth First Search in division Graph Search of Data Structures & Algorithms II

Answer»

Correct option is (c) Equivalent to number of INDEGREE of the node

To EXPLAIN: In DEPTH 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 stack.



Discussion

No Comment Found

Related InterviewSolutions