DEV Community

Mujahida Joynab
Mujahida Joynab

Posted on

BFS & DFS

Breadth First Search is like lever Order Traversal
Depth First Search is like Pre Order Traversal

BFS -

Let's take a graph .

Image description

Image description

Let's take queue .
Let's take a vertex . Any vertex . Let's take 1
Add it in queue . 1
In 1 we have 4 and 2
So , Let's enqueue 1 4 2

1 4 2 3 1

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