DFS:
-Stands for "Depth first search"
-This algorithms are used to traverse a graph in a depthward motion and uses a stack remember to get the next vertex to start a search, when a dead end occurs in any iteration.
Which data structure use to implement DFS ?
"Stack" is used to implement this.
Steps:
Step1:
visit the adjacent unvisited vertex. Mark it as visited. Display it. Push it in a stack.
Step2:
If no adjacent vertex is found, pop up a vertex from the stack.(It will pop up all the vertices from the stack, which do not have adjacent vertices)
Step3:
Repeat Step1 and step2 until the stack is empty.