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)