Encyclopedia > Depth-first search

  Article Content

Depth-first search

Depth First Search (DFS) is a way of traversing or searching a Tree_(graph_theory) or Tree structure. Intuitively, you start at the root and explore as far as possible along each branch before backtracking.

Formally, DFS is an uninformed search that progresses by expanding the first child node of the search tree that appears and thus going deeper and deeper until a goal state is found, or it hits a node that has no children. Then the search backtracks and starts off on the next node.

From an algorithmic point-of view, all freshly expanded nodes are placed at the front of the search queue for expansion.

  • DFS is complete - if the tree is finite, then a solution would be found if one exists.
  • DFS is optimal with a finite tree and all non-negative path costs.

Space complexity of DFS is much lower compared to BFS (Breadth-first search). It also lends itself much better to heuristic methods of choosing a likely-looking branch.


Compare Breadth-first search.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Great River, New York

... and 5.5% have someone living alone who is 65 years of age or older. The average household size is 3.04 and the average family size is 3.36. In the town the population is ...

 
 
 
This page was created in 61.2 ms