Depth First Search

Depth First Search

DFS(adjacencyList:ListType,v:Integer)

S: Stack

initialize S to Empty;

visit and mark v;

push v into S;

while S is non-empty do

for each unmarked vertex w adjacent to TOP(S) do

visit and mark w;

push w into S;

endfor;

POP(S);

endwhile

end DFS

Previous slide Next slide Back to the first slide View Graphic Version