Skip to content

Glossary: Coding Interviews in Java

BFS (breadth-first search)

Also written: BFS, BFS on a grid

A search that uses a queue to visit cells or nodes in order of distance from the start, so the first time it reaches the goal is by the fewest steps. It is used to find the shortest path across a grid, such as a warehouse floor.

Where the book teaches it

Related terms

GridArrayDequeDFS (depth-first search)Visited array