00:01
Hello student, to find the solution path using the depth first search we will start at node 1 and recursively explore all the neighbors.
00:13
If we find a neighbor with a value of 7 we will add it to the solution path and return.
00:18
Otherwise we will continue exploring the neighbors until we find the solution that satisfies the constraint.
00:24
So here constraint is the cost must be 7.
00:27
Here is a pseudocode to implement the depth first algorithm.
00:32
So here dfs is the name of the function and here argument are node, solution path and the path value underscore sum this is giving us the cost.
00:44
So if value underscore sum is equal to 7 then return the solution path it means we have found the solution and add in the solution path.
00:53
4 neighbors in the node neighbors node dot neighbors so here new solution path is equal to solution underscore path dot copy.
01:03
So new underscore solution underscore path now append in the append that and so after append by the neighbors new underscore value underscore sum equal to value underscore sum plus neighbor underscore value.
01:17
So here this will give us the new underscore value by adding the neighbor value in the existing value underscore sum.
01:24
If path now it will give us the path by calling the dfs algorithm neighbor new underscore solution underscore path and new underscore value underscore sum.
01:37
It means it act as a recursively...