Classic weighted shortest path setup, so Dijkstra is the obvious answer.
Start by clarifying the problem constraints: graph size, edge weight properties (negative, zero, positive), and whether it's a single query or repeated. Then select the appropriate algorithm: Dijkstra for non-negative weights, Bellman-Ford for negative weights, or A* if a heuristic is available. Explain the algorithm's steps, complexity, and edge cases, and optionally discuss optimizations like early termination or bidirectional search.
Pro tip: Always ask about edge weight properties and graph size before jumping to an algorithm; mentioning that Dijkstra fails with negative edges and suggesting Bellman-Ford or Johnson's algorithm shows depth. Also, discuss practical optimizations like using a priority queue with decrease-key or a Fibonacci heap for dense graphs.
Ask about graph size, edge weight ranges (negative? zero? positive?), whether the graph is directed or undirected, and if there are multiple queries. This determines the algorithm choice.
Based on constraints, select the best algorithm: Dijkstra for non-negative weights, Bellman-Ford for negative weights, A* if a heuristic exists, or Floyd-Warshall for all-pairs. Justify your choice.
Walk through the algorithm: initialization, priority queue operations, relaxation, and termination. Highlight key invariants and why it works.
State time and space complexity, and discuss how data structures (binary heap, Fibonacci heap) affect performance. Mention trade-offs.
Discuss negative cycles, disconnected graphs, early termination when target is reached, bidirectional search, and A* heuristics if applicable.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.