Why DFS is useful
DFS is a way to search in a graph. A lot of problems can be modelled and solved as a graph problem
Direct Applications
- Listing Directory Structure:
How does a command like
ls -Rmanage to print out every subfolder and file in the correct structure? - Web Crawling: Given a starting URL, how might you explore all reachable pages?
- Course Dependency: If some courses require others as prerequisites, how can you figure out a valid order to take them?
General Applications
In general, what kind of graph problems can DFS solve?
- Topological sorting
- Finding SCC