To find the number of connected components I have used a DFS approach.
I apply DFS for every unvisited node in the given graph and mark that node and its neighbor as visited. On applying DFS every time I increase a counter by 1 which is finally returned as the answer.
I had faced an error of maximum recursion depth exceeded error. To overcome this error I had set a greater recursion depth.
Problem: On being tested with a very large performance test case my code breaks and returns Segmentation fault. (I think because of setting a different recursion limit)
Time Complexity: O(N*(N+E))