I was looking for non-recursive implementation of DFS algorithm.I found the following pseudocode on this page.1  procedure DFS-iterative(G,v):2      let S be a stack3      S.push(v)4      while S is not empty5          v = S.pop()6          if v is not labeled as discovered:7              label v as discovered8              for all edges from v to w in G.adjacentEdges(v) do9                  S.push(w)From what I understand,  if we change the line 8 to be:for all edges from v to w in G.adjacentEdges(v),if w is not discovered doit would speed up the code, because whats the point of pushing already visited vertices on to the stack? Am I right in this assumption?
Making DFS more efficient
algorithms;graphs;graph traversal