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

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

  1. A. 3
  2. B. 4
  3. C. 10
  4. D. 5

Correct answer: D. 5

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic