Algorithm For Time Complexity Of Dfs