How to implement depth first search algorithm(DFS) using java.
DFS (Depth first search) Traversal algorithm can be applied to either Tree or Graph. fig.1 Consider above bi-directional graph, where in there are 10 nodes. If one wants to traverse from node-0 to node-9 Using DFS then in below sequence, nodes will be discovered. node-0 will be added to the stack{0}. node-0 will be removed and node-1 & 7 will be added{1,7}. node-7 will be removed and node-6 & 8 will be added {1,6,8}. node-8 will be removed and node-2 will be added{1,6,2}. node-2 will be removed and node-3 & 5 will be added{1,6,3,5}. node-5 will be removed and node-4 will be added as node-2 & 3 are already visited{1,6,3,4}. node-4 will be removed and node-9 will be added{1,6,3,9}. node-9 will be removed{1,6,3}. node-3 will be removed{1,6}. node-6 will be removed{1}. node-1 will be removed{}. So, {0,7,8,2,5,4,9,3,6,1} will be the node traversal order. Solution: Below is the implementation of DFS in java using Stack as a d...