This was basically a full 45-minute question.
Start by formalizing the graph model and composite cost function, then choose a shortest-path algorithm (e.g., Dijkstra with a binary heap) that supports dynamic edge weights and top-K alternatives. Discuss extensions like A* with admissible heuristics, dynamic updates via incremental algorithms, and turn-by-turn generation from the path. Validate correctness with invariants and test edge cases like disconnected components.
Pro tip: Emphasize that the composite cost must be a linear combination of normalized factors to avoid unit mismatches, and that top-K alternatives require a k-shortest paths algorithm (e.g., Yen's) rather than simple Dijkstra. Also, mention that dynamic closures can be handled with lazy deletion or by recomputing affected shortest paths.
Define vertices as intersections and edges with attributes (distance, bike-lane, elevation, traffic). Propose a composite cost as a weighted sum of normalized attributes, ensuring non-negative weights.
Use Dijkstra with a priority queue (binary heap or Fibonacci heap) for single-source shortest path. For top-K, use Yen's algorithm or Eppstein's algorithm. For dynamic updates, consider dynamic shortest path algorithms or recomputation with caching.
Apply A* with an admissible heuristic (e.g., Euclidean distance scaled by minimum cost per unit) to speed up queries. For road closures, mark edges as infinite weight and update affected paths lazily or via incremental recomputation.
After computing the path, traverse edges and compute turn angles using coordinates of consecutive vertices. Map angles to instructions (left, right, straight) and include distance and street names.
Prove Dijkstra's correctness with non-negative weights, and analyze time complexity (O(E log V) for Dijkstra, O(K V (E log V)) for Yen's). Test edge cases: disconnected components, zero-weight edges, and dynamic updates.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.