Iterative DFS vs Recursive DFS and different elements order
Both are valid DFS algorithms. A DFS does not specify which node you see first. It is not important because the order between edges is not defined [remember: edges are a set usually]. The difference is due to the way you handle each node’s children. In the iterative approach: You first insert all the elements … Read more