Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Fastest way to check the number of nodes reachable from source node

$
0
0

I was doing a problem which involved finding number of reachable nodes from a source node. I implemented this via dfs. I was wondering whether this was the fastest way to check or whether there was any other algorithm I should be looking at.

On an unrelated node: If I implement an algo by using 1.)recursion with memoization or 2.)by iterating , and if the time complexity of both implementation is same which one would execute faster(i.e. if there would be any difference). Does the compiler handle recursion faster than iteration or vice-versa?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>