grokking-algorithms/chapter7/README.md

9 lines
602 B
Markdown
Raw Normal View History

2024-01-12 13:33:29 +00:00
# BFS DFS on rooted tree (connected acyclic graph)
2024-01-12 12:19:51 +00:00
The BFS example uses a queue which results in a breadth first search. When a directory is found its contents are appended to the queue to be processed later
The DFS example uses the call stack which results in a depth first search. When a directory is found it is recursively passed to files_with_extension to be processed immediately.
2024-01-12 13:33:29 +00:00
Note. DFS cannot be used to find the shortest path. In the mango seller example, a DFS search may have found a second or third degree
seller before a first. However, DFS may be used to find the topological sort.