Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

C%20%20%20Interview%20Questions%20and%20Answers

Question: Write the psuedo code for the Depth first Search.
Answer:
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".
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook