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

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

  1. A. 8
  2. B. 7
  3. C. 11
  4. D. 6

Correct answer: B. 7

Run Dijkstra from A: A=0, B=7, C=16, D=3, E=2, F=19. The fewest-edge path (BFS) is not necessarily the lightest.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic