Describe the A* Search Algorithm and its applications.

Instruction: Explain how the A* Search Algorithm works and in what scenarios it is most effectively used.

Context: This question aims to assess the candidate's understanding of the A* Search Algorithm, a computer algorithm that is widely used in pathfinding and graph traversal.

Updated

Official answer

A* orders frontier candidates by f(n)=g(n)+h(n), where g is the best discovered start-to-node cost and h estimates remaining cost. It relaxes outgoing edges, updates improved costs and predecessor links, and checks for the goal when removing a current minimum-priority candidate, not merely when first generating it.

For a finite graph with nonnegative edge costs, use an admissible heuristic (never above the true remaining cost), h(goal)=0, and correctly handle improved paths. A graph-search implementation that permanently closes nodes normally relies on a consistent heuristic: h(u)≤cost(u,v)+h(v) for every edge. With an admissible but inconsistent heuristic, it may need to reopen previously expanded nodes. Skipping stale priority-queue entries is also important.

If h is zero everywhere, the method becomes Dijkstra's search. On a four-neighbor unit-cost grid, Manhattan distance is admissible; allowing cheap diagonal moves can invalidate that choice. Straight-line distance can lower-bound distance, but is not automatically a lower bound on travel time unless converted using valid speed/cost assumptions.

A* supports pathfinding and planning, but a weak heuristic may explore much of the graph and consume substantial memory. Changing traffic or obstacles needs a defined replanning strategy. State the graph, heuristic and implementation assumptions before claiming optimality or efficiency.

Related Questions