in Algorithms retagged by
253 views
1 vote
1 vote

Consider the following graph.

How many nodes (apart from $s$) does the Depth First Search algorithm discover before discovering $t$ when starting from $s.$

in Algorithms retagged by
by
253 views

1 Answer

0 votes
0 votes
We can see the graph can be divided into 4 vertical layers with 3 nodes in each layer. In each layer there is exactly one edge to the next layer and no way to go back or stay in the same layer. Hence starting from s, each layer will give us 4 nodes before we discover t.

Related questions