Computer science: breadth-first search

Self-tutoring about computer science: the tutor mentions breadth-first search.

Let’s imagine you want to search for a book in your three-room apartment. In a breadth-first search (BFS), you’d plan to peek in each room in case it’s lying out where you can see it in one of them. If you don’t find it in that step, you’d search the bookshelf of each room (until you find it). Still not finding it, you’d search the desk of each room, and so on. The point is that you never search the “next” item (for instance, desk) in one room until you’ve searched the “previous” item (for instance, bookshelf) in all the rooms.

In a folder system BFS means checking all adjacent folders before checking a folder inside one of them.


Goodrich, Michael T. and Roberto Tamassia. Algorithm Design. Hoboken: John Wiley & sons, 2002.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply