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

In the undirected graph with edges A–B:1, B–C:8, C–D:10, A–E:11, C–F:11, A–C:5, E–F:6, F–B:6, what is the shortest-path distance from A to D?

  1. A. 16
  2. B. 15
  3. C. 12
  4. D. 21

Correct answer: B. 15

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic