Will Depth-First Search (DFS) invariably yield sub-optimal solutions?
No. DFS can return an optimal solution if it encounters one first, but it provides no guarantee that the first solution has the fewest actions or lowest cost.
Is it possible for DFS to discover solutions superior to the optimal solution?
Certainly not; such solutions would either be invalid (involving impossible moves) or indicate an error in your estimation.
Does this imply that depth-first search (DFS) has no practical applications?
When is it appropriate to use DFS?
Breadth-first search (BFS) expands its frontier systematically in all directions, leading to rapid growth in memory requirements.
DFS often has a smaller frontier because it follows one branch before trying alternatives. However, the code shown here retains every reached state and copies paths into frontier entries. Its total memory is therefore not limited to the active branch, and a small frontier alone does not establish low total memory usage.
The usual small-memory description of DFS applies to implementations that retain the active path and pending alternatives, without a global record of all reached states. Such backtracking implementations can be useful when systematically exploring possible solutions. Their duplicate-handling and termination properties differ from those of the graph-search code above.
The programming language Prolog uses depth-first backtracking to search for answers. It can enumerate answers, but an infinite branch can prevent it from reaching other answers.
Completeness means finding a solution whenever one exists. Both graph-search implementations shown here are complete on a finite reachable state space because each state is added at most once. BFS also finds a finite-depth solution with finite branching in an infinite space; DFS can instead follow an infinite branch indefinitely.
These numerical results apply to the specified initial board and successor order. Expansion counts describe search effort, not elapsed time or peak memory; different boards or move orders can change the comparison substantially.
Depth-limited and iterative deepening search would be alternative uninformed search algorithms.
Heuristic functions use additional knowledge to estimate the remaining cost to a goal and guide search. They are the focus of the next lecture.