DFS involves following a path from source vertex to adjacent vertices until there are no other vertex is left to visit.
Objective
- Start with source vertex, push it into stack, mark it visited and display it
- Now peek the stack and look for adjacent vertices.
- If found push it into stack, mark it visited and display it.
- If not, then pop up from stack and again repeat step 2.
- Repeat till stack is empty.