Aug 13, 2022
Hi Saurabh, the space complexity would still be O(V) as the recursive stack will also have a space complexity of O(V). This is because we call the DFS() once for every unvisited node.
Hi Saurabh, the space complexity would still be O(V) as the recursive stack will also have a space complexity of O(V). This is because we call the DFS() once for every unvisited node.
Software Engineer at Google | I try to learn and blog