This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
How do I convert following recursive algorithm to iterative
DFS-Visit(U)
color[u] = GREY
d[u] =time
time = time + 1
for each v = Adj[u] do
if color[v] = WHITE
开发者_开发技巧 then p[v] = u
DFS-Visit(v)
color[u] = BLACK
f[u] = time
time = time + 1
USE stack to save the state instead..of calling it recursively
this might help you : http://www.cs.mcgill.ca/~pnguyen/251F09/DFS.pdf
精彩评论