0 0 votes In an adjacency list representation of an undirected graph G = (V,E), for any 2 sets of vertices V1 and V2 let, distance (V1,V2) be defined as the minimum of the length of shortest distance between a vertex in V1 and V2, if V1 ∩ V2 ≠ ∅, then distance (V1,V2) = 0. the most optimal time complexity for computing distance (V1,V2) is : WHAT KIND OF SETS IT IS TALKING ABOUT .....?AND HOW IT CAN BE FORMED PLEASE GIVE EXAMPLE . Algorithms graph-algorithms + – eyeamgj 1.8k views answer comment Share Follow Print See all 15 Comments 15 15 Comments reply Show 12 previous comments kumar.dilip commented Nov 21, 2018 reply Follow flag I think the answer will be O(E + V). 0 0 replyShare Shaik Masthan commented Nov 22, 2018 reply Follow flag provide your algorithm 0 0 replyShare Nitinkumar.097 commented Dec 26, 2020 reply Follow flag Options Are: O(VE) O(V+E) (Given as Correct) O($V^{2}$) O($EV^{2}$) To compute the distance (G1,G2), take 2 new vertices x and y, connect x to all vertices in G1 and y all vertices in G2, then perform a BFS from x to y. The length of the path obtained minus 2 (one edge from x and one from y) will give the result. Time complexity of BFS is O(V+E). 0 0 replyShare Please log in or register to add a comment.