Question d’entretien chez Palantir Technologies

How would you find the shortest path between two nodes in a graph? Write code in Java to do this.

Réponses aux questions d'entretien

Utilisateur anonyme

29 août 2015

This problem, if asked vaguely, aims to test the interviewer's knowledge of ALL shortest-path algorithms. For example, if I were the interviewer, I would ask more details about the graph: if the graph is unweighted, then a simple BFS will suffice. If the graph has negative weight, then dijkstra won't work. If this shortest-path query is going to appear multiple times, use Floyd-Warshall. If there is negative weight, or parallel computing is available, then Bellman-ford.

4

Utilisateur anonyme

8 juil. 2009

Read Wikipedia for information about depth-first search, breath-first search, and breadth-first-search from both endpoints to give a good answer to this question.

1

Utilisateur anonyme

12 sept. 2010

you can use dijkstra's algorithm... its very similar to building a minimum spanning tree using the prims algorithm

1