Skip to content

Glossary: Data Structures and Algorithms

Depth-first search (DFS)

Also written: DFS, depth-first search

A way to explore a graph by going as deep as possible down one road before backing up to try the next, using recursion or a stack. It finds everything reachable from a place.

Where the book teaches it

Related terms

Breadth-first search (BFS)RecursionStackvisited set