--

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.

--

--

Anshika Bhargava
Anshika Bhargava

Written by Anshika Bhargava

Software Engineer at Google | I try to learn and blog

No responses yet