How to convert from recursive algorithm to iterative [closed]
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
精彩评论