Backtracking

Depth-First Search and Backtracking

Introduction to DFS (Depth-First Search) What is a Search Algorithm? A search algorithm exhaustively explores part or all of the solution space of a problem to find its solution. Depth-First Search (DFS) Essence: DFS is essentially brute-force enumeration. “Depth-first” principle: Go as far down one path as possible; only backtrack when no further progress can be made. Example: Finding a Path from Node 1 to Node 8 Starting from node 1, always move to an unvisited node if one exists; otherwise, backtrack.

Read note →