Today I had a test (Data Structures course), and one of the questions was as follows: Given the undirected, non-weighted graph G = (V, E), you need to write an algorithm that for this node s returns the shortest path from s to all nodes v 'in the complement graph.
The complement graph G '= (E', V ') contains an edge between any nodes in G that do not share an edge, and only those.
The algorithm should be executed in O (V + E) (the original graph).
I asked 50 different students, and even one of them did not solve it correctly.
any ideas? Thanks a lot, Barak.
source
share