Depth-First Search
Version 1.0.0 · Updated 2026-07-30
CORE DEFINITION
A traversal/search strategy: go all the way down one path until no further progress is possible, then backtrack and try another path. The counterpart is breadth-first search (exploring all adjacent options first).
SCAFFOLDING EFFECT
Reduce cognitive load
Clarify the choice between "depth-first" and "breadth-first". Each strategy has its applicable scenarios: - Depth-first: when the solution is likely deep, or when a complete path is needed - Breadth-first: when the solution is likely shallow, or when the shortest path is needed
Anchor fast decisions
DFS: starting from the origin, go as deep as possible along one branch, then backtrack to explore sibling branches upon reaching a leaf; can be implemented with a stack or recursion, space is better than BFS, but does not guarantee finding the shortest path.
MINIMUM ACTION
In progress 0/4Practice this model in one real situation:
account_treeGenealogyexpand_more
menu_bookReferencesexpand_more
Source support: Explicit
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Depth-first_searchverified
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS