My first instinct was BFS and I had to stop myself.
Clarify that the graph may have non-negative or negative weights, then select the appropriate algorithm: Dijkstra for non-negative weights, Bellman-Ford for negative weights without negative cycles, or Floyd-Warshall for all-pairs. Explain the algorithm's steps, complexity, and why it's optimal for the given constraints.
Pro tip: Always ask about edge weight constraints (negative? zero?) and graph size; this shows you understand real-world trade-offs and avoids choosing an incorrect algorithm.
Ask about edge weight properties (negative, zero), graph size, and whether the graph is directed or undirected. This determines the algorithm choice.
Select Dijkstra for non-negative weights, Bellman-Ford for negative weights (and detect negative cycles), or Floyd-Warshall for all-pairs shortest paths. Justify your choice.
Walk through the algorithm: initialization, relaxation, and termination. For Dijkstra, mention priority queue; for Bellman-Ford, mention V-1 iterations and cycle check.
State time and space complexity: Dijkstra O((V+E) log V) with binary heap, Bellman-Ford O(VE), Floyd-Warshall O(V^3). Discuss trade-offs.
Discuss disconnected graphs, negative cycles, and unreachable nodes. Mention how to reconstruct the path using parent pointers.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.