Write the psuedo code for the Depth first Search.

dfs(G, v) //OUTLINE
Mark v as “discovered”
For each vertex w such that edge vw is in G:
If w is undiscovered:
dfs(G, w); that is, explore vw, visit w, explore from there as much as possible, and backtrack from w to v. Otherwise:
“Check” vw without visiting w. Mark v as “finished”.

Author: on September 3, 2010
Category: C++ Interview Questions
  • Recently in C++ Interview Questions:

  • Recent questions

    Copy Protected by Send free sms - Love2sms.