Skip to content

Glossary: Coding Interviews in C++

DFS (depth-first search)

Also written: DFS, depth-first search, DFS flood fill

A search that follows one path as far as it can before backing up to try another, usually written with recursion. It is used to flood fill a grid, for example marking every cell of one island of shelves as visited.

Where the book teaches it

Related terms

Flood fillIslandCall stackBFS (breadth-first search)