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?