DEV Community

Cover image for Breadth-First Search
Nicko Cruz M
Nicko Cruz M

Posted on

1

Breadth-First Search

This is a submission for DEV Computer Science Challenge v24.06.12: One Byte Explainer.

Explainer

I want to find something in my strange house, that has n-floors. I must check all the rooms on the curr floor if I find it then I'm done. If I don't find it in any of the rooms on that floor then, AND ONLY THEN, will I go down to the next floor.

Additional Context

This is my attempt to explain BFS using the strange house that is (n) stories tall to act as a representation of the tree data structure. The given example is meant to emphasize the BREADTH in breadth-first search.

When studying algorithms in college it is obvious, in hindsight, the differences between DFS and BFS. However, during undergraduate studies, it is easy for the obvious to become obscured.

With this in mind, I wanted to focus on what makes the Breadth-first approach different from other approaches, which is the fact that this algorithm searches all nodes at the current depth, before traversing nodes at a deeper levels.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay