A star algorithm using Heuristic value to act as Tie-breaker where nodes have identical F-values
Data Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.
Introduction
The A* algorithm is a powerful search algorithm widely used in pathfinding and graph traversal. It dynamically finds the shortest path between a start node and a target node using a heuristic-driven approach. Typically employed in domains like AI for games, GPS navigation systems, and puzzle solving, the A* algorithm balances the cost of the current path and the cost estimated to reach the goal, making it both complete and optimal given an admissible heuristic.
Core Concepts of the A* Algorithm
Components
The A* algorithm uses the following components:
- Open list: A set of nodes to be evaluated.
- Closed list: A set of nodes already evaluated.
- : Represents the cost from the start node to node .
- : Represents the heuristic estimate of the cost from node to the goal.
- : Represents the total estimated cost of the cheapest solution through node . Calculated as .
Process Flow
- Initialize: Start with the open list containing the start node and an empty closed list.
- Iteration:
- Choose the node from the open list with the lowest .
- If is the goal, reconstruct the path and return it as the solution.
- Move from the open list to the closed list.
- For each neighbor of , update costs and add to the open list if not already evaluated.
- Repeat until the goal is reached or the open list is empty.
Heuristic as a Tie-breaker Strategy
Identical -values can create ambiguity when selecting nodes from the open list. To resolve ties, a secondary sorting criterion is needed—the heuristic value . A* can employ as a tie-breaker to prioritize nodes with smaller heuristic values, thereby steering the exploration towards regions more likely to contain the goal.
Why Use a Tie-breaker?
- Directs Search Efficiently: With multiple nodes having the same -value, using potentially accelerates the process by favoring nodes closer to the destination.
- Reduces Computational Overhead: Minimizes the number of nodes expanded when reaching out from ties, leading to computationally cheaper solutions.
Example of Tie-breaking
Consider a simple grid with open spaces and obstacles. Suppose for two neighboring nodes, and , with and . Here’s how using the heuristic as a tie-breaker directs the search towards areas with lower heuristic estimates:
- Node A: , so
- Node B: , so
Given they have the identical -values:
- Select Node A: This choice uses to guide the algorithm through areas that potentially require fewer steps to reach the goal.
Technical Considerations
Admissible Heuristics
For A* to guarantee the optimal path, the heuristic function must be admissible, meaning it never overestimates the actual cost to reach the goal.
Computational Complexity
The performance of the A* algorithm largely depends on the accuracy of the heuristic function. A more informed heuristic leads to fewer nodes being expanded, improving both time and space complexity.
Memory Usage
A* maintains a record of all explored paths, meaning both open and closed lists can grow substantially, creating high memory consumption for large graphs.
Key Point Summary
| Aspect | Description |
| Algorithm Type | Graph search, pathfinding |
| Data Structures | Open list, closed list |
| Cost Functions | : cost from start to node : heuristic estimate from node to goal |
| Tie-breaking | Use to resolve tie when nodes have identical -values |
| Heuristic Types | Admissible (never overestimates) Consistent (monotonic, always satisfies triangle inequality) |
| Complexity | Depends on heuristic efficiency Potentially exponential especially with uninformed heuristics |
| Practical Applications | GPS navigation, AI pathfinding in games, puzzle solving |
| Challenges | High memory usage due to retaining paths in both open and closed lists |
| Optimization Techniques | Using a proper data structure for open list (e.g., priority queues) Employing domain-specific heuristics |
Conclusion
Employing the A* algorithm with different tie-breaking strategies, such as using heuristic values as secondary ordering criteria, can facilitate efficient pathfinding in complex graphs. Understanding and implementing effective heuristics is key in ensuring optimality and speed in obtaining solutions. As A* continues to be a cornerstone in AI and robotics, these strategies help tackle challenges related to computational expenses and search quality.
Related reading
- A two way minimum spanning tree of a directed graph
- A weighted version of random.choice
- About accuracy in recommendation system
- About bubble sort vs merge sort
- A task/job scheduling problem
- Abnormally high MySQL writes and larger than normal Binary Log files. How can I determine what caused this?
- About distributed logical clock, Lamport Algorithm
- Absolute distance from various points in On

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.