What is the time taken(number of steps) in this problem by applying DFS?

Revision en1, by sankalp_, 2018-05-11 02:27:04

I came across this problem and I submitted a DFS solution and it got AC.

But it took way lesser time than I expected it to take.

Like...

Forgetting all the vertices which can't be reached, at every level we have 10 new vertices and the depth is 1000 in the worst case.

Wouldn't a DFS have a huge number of steps and this code took around 30ms.

Any reasoning as to why my reasoning is wrong would be highly appreciated :)

Tags #graphs, #dfs, #time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sankalp_ 2018-05-11 02:27:04 618 Initial revision (published)