00:01
Hello student, here the graph is given to us and this is the given graph here level 0, level 1 and level 2.
00:08
I have to explore this graph, this node g with the help of both bfs and dfs.
00:14
So first i will discuss the bfs.
00:16
Suppose the bfs, we are taking the bfs, so bfs will visit the less number of the nodes.
00:23
So this is the answer.
00:24
But how bfs work? by exploring all of the nodes at the same level before moving to the next level.
00:31
So in this case, starting node at the level is 0.
00:34
So bfs will first explore all the nodes at the level 1.
00:38
So at the level 1, there are two nodes b and c, which are b and c.
00:42
Then bfs will explore all the nodes at the level 2.
00:45
So b having two nodes and c having two nodes.
00:49
So but in a c, there is a g.
00:53
So here look at the graph in a branching of b.
00:58
This is the goal node, which we have to visit.
01:01
So here s from start s, then it will explore this abc.
01:07
After exploring the abc, now it will go to, when it will go to the b, then it will explore this and this and here the goal node matches.
01:17
So bfs work will complete here because we have to reach towards the node g.
01:23
So finally g.
01:24
So bfs will explore the node at the level 2.
01:27
Now dfs.
01:28
So dfs on the other end, work by exploring the branch of the graph as far as possible before moving to the next.
01:35
In this case, dfs would start at the starting node s and explore the branches at the level leads to l.
01:42
So here suppose l.
01:43
Suppose this level is l.
01:46
So i am taking as a generalized value.
01:49
So once dfs reaches l, it would backtrack.
01:52
So here it will do the backtracking because the particular node is not found and exploring for the g.
02:00
Since bfs will explore all the nodes at the same level before moving to the next level, it will visit the goal node g sooner than the dfs because in the dfs case backtracking will happen because it will go deep and deep into the one branch.
02:15
In this case, bfs will visit three nodes.
02:19
What are these? s, b and c before visiting g...