🧮Depth-First Search (DFS)
Also known as DFS, Depth First Search
Walking a graph down one path as far as it goes, then backing up.
Think of it like
Think of it like a maze. Follow one path to the end, then go back and try the next.
Example
Jack's puzzle solver tries one move after another until it gets stuck. Then it backs up one move and tries the next one.
Why it matters
Many puzzle solvers and maze games are built on it.
Definition
Common mistake
Key takeaways
- 1Deep first. One path to the end.
- 2Back up at dead ends. Then try the next branch.
- 3Stack or recursion. Keeps its place.