Data Structures & AlgorithmsVery hardICPC regional · algorithm theory

Problem: Johnson's algorithm reweights edges with potentials before running Dijkstra. What does the reweighting achieve?

  1. A. It removes all cycles from the graph
  2. B. It doubles every weight
  3. C. It converts the graph to a tree
  4. D. It makes all edge weights non-negative without changing shortest paths

Correct answer: D. It makes all edge weights non-negative without changing shortest paths

Potentials h(v) from Bellman-Ford give w'(u,v) = w(u,v) + h(u) - h(v) >= 0, and shortest paths are preserved.

More Coding Interview Problems questions

Exams that ask this topic