2 votes 2 votes The problem of finding the set of vertices reachable from a given vertex in a graph can be solved in time A. O(|V|^2) B. O(|V| + |E|) C. O(|V||E|) D. none of these Algorithms graph-theory graph-algorithms + – Abhisek Saha asked Jul 15, 2017 Abhisek Saha 553 views answer comment Share Follow See 1 comment See all 1 1 comment reply kunal shahare commented Sep 20, 2019 reply Follow Share What if adjacency matrix used?in that case it would be O(n^2) 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes B) O (V+E) Perform BFS vivek9837 answered Jul 15, 2017 vivek9837 comment Share Follow See all 2 Comments See all 2 2 Comments reply Abhisek Saha commented Jul 16, 2017 reply Follow Share Shouldn't it be DFS ? Question asks for all reachable vertices, not only the adjacent ones. And please explain "how O(V + E) ?" . 0 votes 0 votes vivek9837 commented Jul 16, 2017 reply Follow Share BFS search the graph breadth wise, searching means it picks a source vertex and spans along the width of the graph. Rember it can be used to make a spanning tree If u use adjacency list representation of graph u get a runtime of O(V+E) 0 votes 0 votes Please log in or register to add a comment.