Recall that two vertices in an undirected graph are in the same connected component if there is a path connecting them. A good algorithm to find the connected components of an undirected graph begins by calling a DFS on the first vertex. All vertices reached by the DFS are in the same connected component and are so marked. We then look through the vertex mark array until an unmarked vertex i is found. Again calling the DFS on i, all vertices reachable from i are in a second connected component. We continue working through the mark array until all vertices have been assigned to some connected component. A sketch of the algorithm is as follows:Use the concept of potential from amortized analysis to explain why the total cost of this algorithm is Θ(|V| + |E|). (Note that this will not be a true amortized analysis because this algorithm does not allow an arbitrary series of DFS operations but rather is fixed to do a single call to DFS from each vertex.)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here