Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

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

  1. A. 24
  2. B. 26
  3. C. 25
  4. D. 23

Correct answer: A. 24

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic