Count number of trees in a forest
Problem Statement Given a forest with edge representation, find the number of trees in the forest. Example Input edges = {{0, 1}, {0, 2}, {3, 4}, {4, 5}, {5, 6}} Expected Output 2 Approach The idea is to apply Depth First Search on every node. If every connected node is visited from one source then …