7. Problem - get connected components #
Created Tuesday 31 March 2020
- Keep a bag for getting all nodes
- Run DFS on the starting vertex. Pass the bag as visited for this. Keep filling the bag.
- Do 2 and 3 for all unvisited nodes. Once done stop.
- If visited.size()==V, return true; else return false;
Note: Here we can use two different bags too. But that’s cumbersome. Not required.