Data Structures & AlgorithmsVery hardGATE CS · TCS NQT · Product Company SDE

In the undirected graph with edges A–B:13, B–C:6, C–D:4, B–E:7, E–F:2, A–G:14, C–E:7, A–D:8, what is the shortest-path distance from A to B?

  1. A. 12
  2. B. 13
  3. C. 14
  4. D. 15

Correct answer: B. 13

Run Dijkstra from A: A=0, B=13, C=12, D=8, E=19, F=21, G=14. The fewest-edge path (BFS) is not necessarily the lightest.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic