Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE

In the undirected graph with edges A–B:10, A–C:12, C–D:3, D–E:8, E–F:2, E–A:9, what is the shortest-path distance from A to D?

  1. A. 17
  2. B. 14
  3. C. 18
  4. D. 15

Correct answer: D. 15

Run Dijkstra from A: A=0, B=10, C=12, D=15, E=9, F=11. The fewest-edge path (BFS) is not necessarily the lightest.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic