7. Problem - get connected components #

Created Tuesday 31 March 2020

  1. Keep a bag for getting all nodes
  2. Run DFS on the starting vertex. Pass the bag as visited for this. Keep filling the bag.
  3. Do 2 and 3 for all unvisited nodes. Once done stop.
  4. If visited.size()==V, return true; else return false;

Note: Here we can use two different bags too. But that’s cumbersome. Not required.