Here is the standard pseudocode for breadth first search:
{ seen(x) is false for all x at this point }
push(q, x0)
seen(x0) := true
while (!empty(q))
x := pop(q)
visit(x)
for each y reachable from x by one edge
if not seen(y)
push(q, y)
seen(y) := true
Here push and pop are assumed to be queue operations. But what if they are stack operations? Does the resulting algorithm visit vertices in depth-first order?
If you voted for the comment "this is trivial", I'd ask you to explain why it is trivial. I find the problem quite tricky.
