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

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

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

Correct answer: D. 4

Run Dijkstra from A: A=0, B=14, C=4, D=22, E=15, F=13. The fewest-edge path (BFS) is not necessarily the lightest.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic