If I do a DFS (Depth first search on a undirected graph) I can get different solutions, or is there still only one solution?
If I do a DFS (Depth first search on a undirected graph) I can get different solutions, or is there still only one solution?
Depends on the node you start with. If you start with the same node, then there is one solution.
You could do DFS in reverse order, which obviously gives a different ordering.
However, yes DFS is deterministic. It will give the same result when done multiple times on the same tree. Why wouldn't it?!
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"