Photo by Viktor Talashuk on Unsplash

Hands-on Tutorial

How to Find a File System Efficiently Using Breadth-First Search and Depth-First Search

The performance comparison between Breadth-First Search and Depth-First Search for tree transversal

9 min readNov 15, 2021

--

The idea behind this article came up when I was searching for an important file on my computer. In my mind, I asked myself, how can my computer search for any files in a lot of folders? Before googling it, I tried to figure out the structures of computer drives. It seems like a tree — has a folder, a subfolder, and inside the subfolder, there are folders and again and again until it reaches the dead-end (often it ends with files or an empty folder).

After I knew the data structure, I went to Google and typed an “algorithm to search files on the computer”. There are many answers, but most of them discuss the Breadth-First Search (BFS) and Depth-First Search (DFS).

In this short article, I try to summarize my findings of the BFS and DFS. Hopefully, it can help you understand these algorithms.

Without further ado, happy reading!

Differences between tree and graph

--

--

Data Scientist. Tech Writer. Statistics, Data Analytics, and Computer Science Enthusiast. Portfolio & social media links at http://audhiaprilliant.github.io/