A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Heuristic Search Functions

Graduate Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
16topics build on this
604prerequisites beneath it
See this on the map →
A* Search AlgorithmGreedy Algorithms→→Constraint Satisfaction Problem SolvingLocal Search Optimization
search heuristics admissibility optimization

Core Idea

Heuristic functions estimate the cost from a state to the goal without exploring the full search space, enabling guided search. Well-designed heuristics must be admissible (never overestimate) to guarantee optimal solutions, and consistent heuristics satisfy the triangle inequality to enable efficient pruning. The quality of the heuristic determines whether A* will terminate quickly or explore exponentially many states.

How It's Best Learned

Study examples of admissible heuristics like Manhattan distance for grid puzzles and implement A* with different heuristics to observe how heuristic quality affects search performance.

Common Misconceptions

A faster heuristic is always better (domination matters: h1 dominates h2 if h1(s) ≥ h2(s) for all s). Optimality requires admissibility, not just consistency.

Explainer

From your study of A* search, you know that A* evaluates nodes using f(n) = g(n) + h(n), where g(n) is the cost so far and h(n) is the heuristic estimate of the remaining cost to the goal. The entire performance of A* — whether it finds the optimal solution quickly or degenerates into exhaustive search — hinges on the quality of h(n). A heuristic function is your way of injecting problem-specific knowledge into a general search algorithm, telling it which directions look promising without actually exploring them.

The most important property of a heuristic is admissibility: h(n) must never overestimate the true cost to reach the goal. If h always underestimates (or exactly equals) the true remaining cost, A* is guaranteed to find the optimal solution. Intuitively, an admissible heuristic is optimistic — it never makes a path look worse than it actually is, so A* will never dismiss the optimal path prematurely. The trivial heuristic h(n) = 0 is always admissible (it is maximally optimistic), but it gives A* no guidance, reducing it to Dijkstra's algorithm. The ideal heuristic would equal the true cost exactly — then A* would march straight to the goal without exploring a single unnecessary node. Real heuristics fall between these extremes.

Consider the 8-puzzle (sliding tiles). Two classic heuristics are misplaced tiles (count how many tiles are not in their goal position) and Manhattan distance (sum the number of horizontal and vertical moves each tile needs to reach its goal position). Both are admissible because neither can overestimate — a tile that is out of place needs at least one move, and the Manhattan distance of each tile is a lower bound on its actual moves because it ignores the constraint that other tiles block the way. Manhattan distance dominates misplaced tiles: for every state, Manhattan distance is greater than or equal to misplaced tiles. This domination is precisely what makes it the better heuristic. A dominating heuristic is closer to the true cost, so A* expands fewer nodes — it has tighter guidance about which paths to pursue.

A stronger property than admissibility is consistency (also called monotonicity): for every node n and successor n', the heuristic satisfies h(n) ≤ cost(n, n') + h(n'). This is the triangle inequality — the estimated cost from n to the goal should not exceed the cost of stepping to n' plus the estimate from n'. Consistent heuristics guarantee that when A* expands a node, it has already found the optimal path to that node, so nodes never need to be re-expanded. Every consistent heuristic is admissible, but not every admissible heuristic is consistent (though counterexamples are rare in practice). When designing heuristics, a powerful technique is relaxation: remove some constraints from the original problem, solve the easier version, and use its cost as h(n). Manhattan distance, for instance, is the exact solution to a relaxed 8-puzzle where tiles can pass through each other. This relaxation approach systematically generates admissible heuristics for any problem where you can formalize the constraints.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → Defining and Calling Functions → Functions: Decomposing Problems → Function Parameters and Argument Passing → Return Values → Variable Scope → Introduction to Classes → Objects and Instances → Methods and Attributes → Algorithm Design Basics → Tree Structure and Node Properties → Binary Trees → Tree Traversals → Depth-First Search (DFS) → Depth-First Search: Implementation and Applications → Topological Sort → Dynamic Programming → Longest Common Subsequence (LCS) Problem → Edit Distance: Levenshtein Distance and DP → 0/1 Knapsack Problem: Bounded Capacity DP → Greedy Algorithms → Activity Selection Problem Using Greedy Algorithms → Dijkstra's Algorithm → A* Search Algorithm → Heuristic Search Functions

Longest path: 97 steps · 604 total prerequisite topics

Prerequisites (2)

Leads To (2)