Learn the vocabulary of combining actual distance traveled with a heuristic estimate to reach a goal efficiently.
0 / 5 completed
1 / 5
At standup, a dev mentions a pathfinding algorithm that, like Dijkstra's algorithm, tracks the actual distance traveled so far, but also adds a heuristic estimate of the remaining distance to the goal, to prioritize exploring the most promising nodes first. What is this algorithm called?
A* search is exactly this: it extends Dijkstra's algorithm by adding, to each node's actual distance traveled so far, a heuristic estimate of the remaining distance to the goal, and prioritizes exploring nodes whose combined score looks most promising. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This actual-distance-plus-heuristic-estimate scoring is exactly why A* search can reach a goal much faster than plain Dijkstra's algorithm when a good heuristic is available.
2 / 5
During a design review, the team relies on A* search's heuristic estimate specifically because it never overestimates the true remaining distance to the goal, guaranteeing the algorithm still finds the truly shortest path. Which capability does this admissible heuristic provide?
An admissible heuristic, one that never overestimates the true remaining distance, provides finding the optimal shortest path while still exploring far fewer nodes than plain Dijkstra's algorithm would, since the heuristic steers the search toward the goal without ever being so optimistic that it causes the algorithm to miss the true shortest path. Plain Dijkstra's algorithm, with no such guidance, explores outward more or less uniformly in every direction from the source. This never-overestimate guarantee is exactly what lets A* search stay both fast and provably optimal.
3 / 5
In a code review, a dev notices a pathfinding feature uses plain Dijkstra's algorithm to find a route toward one specific known goal location, exploring outward uniformly in every direction with no sense of which way the goal actually is. What does this represent?
This is a missed A*-search opportunity, since plain Dijkstra's algorithm explores outward uniformly with no sense of direction toward the goal, while adding a heuristic estimate of the remaining distance, exactly what A* search does, would steer the search toward the known goal location and finalize a path while exploring far fewer nodes overall. A cache eviction policy is an unrelated concept about discarded cache entries. This no-heuristic pattern is exactly the kind of missed speedup a reviewer flags once the goal location is already known in advance.
4 / 5
An incident report shows a navigation feature's route-computation latency was far higher than necessary, because it used plain Dijkstra's algorithm exploring outward uniformly in every direction, even though the destination location was already known at the start of every request. What practice would prevent this?
Switching to A* search with an admissible heuristic lets the algorithm steer toward the known destination instead of exploring uniformly outward in every direction, which is exactly the fix for the excessive latency described in this incident. Continuing to use plain Dijkstra's algorithm regardless of whether the destination is already known is exactly what wasted time exploring directions away from the goal. This heuristic-guided approach is the standard fix once a pathfinding feature's destination is known in advance and a suitable admissible heuristic, like straight-line distance, is available.
5 / 5
During a PR review, a teammate asks why the team reaches for A* search instead of plain Dijkstra's algorithm, given that both are guaranteed to find the optimal shortest path when the heuristic is admissible. What is the reasoning?
A* search's heuristic actively steers exploration toward the goal, so it typically visits far fewer nodes than Dijkstra's algorithm's more uniform outward exploration, especially on a large graph with a known destination. The tradeoff is that A* search needs a good, genuinely admissible heuristic tailored to the specific problem, like straight-line distance for a map, and a poorly chosen heuristic can erode or even eliminate that advantage. This is exactly why A* search is favored whenever a reliable admissible heuristic exists, while plain Dijkstra's algorithm remains simpler when no such heuristic is available.