datarekha

Heuristics & Admissibility

A heuristic h(n) estimates the cost from a node to the goal. Admissible means it never overestimates; consistent means it obeys the triangle inequality — and consistent implies admissible.

7 min read Intermediate GATE DA Lesson 99 of 122

What you'll learn

  • A heuristic h(n) is an estimate of the cost from node n to the goal — it powers informed search (A*, greedy)
  • Admissible ⇔ h(n) is never more than the true cost-to-goal — the condition A* needs to be optimal
  • Consistent (monotone) ⇔ h(n) ≤ cost(n→n') + h(n') for every successor — and consistent implies admissible
  • The largest admissible heuristic at a state IS its true cost-to-goal; anything larger overestimates somewhere

Before you start

Imagine you’re driving from one city to another, and at every intersection a friendly voice whispers, “you’ve still got roughly 40 km to go.” You don’t know if it’s exact — maybe the road bends or there’s traffic — but the estimate is honest: it never tells you the rest of the trip is shorter than it really is. That honesty is the whole point of a heuristic in search.

A heuristic doesn’t have to be perfect. It just has to point you in the right direction without lying about how close the goal is. When it satisfies that one rule, the informed-search algorithm sitting on top of it (A*) is guaranteed to find the cheapest solution. This is exactly the knob engineers tune in real route planners and game AI: a sharper admissible heuristic explores far fewer states, so the same idea is what makes a maps app return a route in milliseconds instead of seconds.

The heuristic h(n)

Formally, h(n) is a function that takes a state and returns an estimate of the cost to reach the goal from there. The true cost is usually written h*(n). The relation between h and h* is what matters.

  • Greedy best-first search expands by smallest h(n).
  • A* expands by smallest f(n) = g(n) + h(n) — actual cost so far plus estimated cost-to-go.

A* is only as good as its heuristic. So we need a way to tell which heuristics behave well.

Admissible — “never overestimates”

A heuristic is admissible if, for every state n,

  h(n) ≤ h*(n)         (h*(n) is the true optimal cost from n to a goal)

That’s it. It’s allowed to under-estimate (even all the way down to 0 — yes, h(n) = 0 is admissible; A* then degrades to UCS). It is not allowed to overestimate, ever, at any single state.

Why does this matter? Because A*‘s optimality proof rests on it. If h is admissible, then any path A* commits to at the goal has f = g + h = g + 0 = g, and no other partial path on the frontier has a smaller f — so the goal really is reached by the cheapest path. Overestimate at even one node, and A* can be fooled into committing to a worse path.

Sh=8Ah=5Bh=7Ch=2Gh=032462
Each node carries a heuristic h. True costs to G: h*(S)=9, h*(A)=6, h*(B)=8, h*(C)=2. So h=8, 5, 7, 2 are all admissible at S, A, B, C — none overestimates.

Consistent — “the triangle inequality”

A heuristic is consistent (or monotone) if for every state n and every successor n' reached by an action of cost c(n, n'),

  h(n) ≤ c(n, n') + h(n')

Read it as: my estimate from n shouldn’t be more than the cost of one step plus my estimate from where I land. (If it were, the estimate would jump up by an impossible amount.)

Consistent ⇒ admissible. Walk an entire optimal path applying the inequality step by step and the estimate h(n) ends up bounded by the true cost-to-goal. The converse fails: there are admissible heuristics that violate the triangle inequality at some edge.

When you implement A* with a consistent heuristic, f values along any path are non-decreasing, and you never need to re-open a closed node. With merely admissible, A* still finds the optimum, but the graph-search version may need to re-open nodes.

The largest admissible heuristic IS the true cost-to-goal

A neat squeeze argument. The admissibility condition is h(n) ≤ h*(n). So the largest value h can take at state n without violating admissibility is exactly h*(n). Any larger value would overestimate at that one node — making the heuristic inadmissible.

That’s also why “the true cost is itself an admissible heuristic” — it sits right on the boundary. (And it’s the perfect heuristic: A* with h = h* expands exactly the nodes on the optimal path.)

Worked example

Based on the 2024 paper, Q27. A search problem has a state n whose true optimal cost to the goal is h*(n) = 10. Candidate heuristic values at n are 0, 5, 8, 10, 12. Which are admissible at n? Which is the largest admissible value?

Apply h(n) ≤ 10 to each:

  h = 0   →  0 ≤ 10 ✓ admissible (always — h = 0 makes A* into UCS)
  h = 5   →  5 ≤ 10 ✓ admissible
  h = 8   →  8 ≤ 10 ✓ admissible
  h = 10  → 10 ≤ 10 ✓ admissible — and this is the largest possible
  h = 12  → 12 ≤ 10 ✗ NOT admissible (overestimates)

So all values up to and including 10 are admissible; h = 10 is the largest.

If you used h(n) = 12 inside A*, the algorithm could be tricked: a partial path with true cost-to-go of 10 would look worse than an alternative whose g + h was lower, and A* might commit to the wrong path — losing the optimality guarantee.

Based on 2024 Q46-style. A graph has h-values h(A)=4, h(B)=2, h(C)=1, h(D)=0 with D the goal. The true costs-to-goal are h*(A)=5, h*(B)=2, h*(C)=1, h*(D)=0. Is h admissible? Is it consistent?

Admissible: check h(n) ≤ h*(n) at every node — 4 ≤ 5, 2 ≤ 2, 1 ≤ 1, 0 ≤ 0. Yes, all four hold. So h is admissible. Consistency would require checking the triangle inequality on every edge; given just node-values, the per-node admissibility test is the conservative answer.

How GATE asks this

Two recurring shapes — both appeared in 2024. MSQ: a list of candidate heuristics with their values at each state, plus the true costs-to-goal; pick the ones that are admissible / consistent. MCQ or NAT: given a state with a known true cost h*(n) = k, the largest admissible value at that node is k. Both reduce to the same test: write down h(n), write down h*(n), check h(n) ≤ h*(n) at every node.

Quick check

Quick check

0/6
Q1A heuristic h is admissible at state n exactly when which condition holds?
Q2State n has true cost-to-goal h*(n) = 7. What is the LARGEST integer value of h(n) for which h is admissible at n?numerical answer — type a number
Q3True costs to the goal are h*(A)=10, h*(B)=6, h*(C)=4. Which of the following heuristics are ADMISSIBLE on this state space? (select all that apply)select all that apply
Q4Which statements about admissible and consistent heuristics are TRUE? (select all that apply)select all that apply
Q5On a graph with goal G, the heuristic gives h(A)=3, h(B)=5, h(G)=0. The edge A→B has cost 1. The consistency condition at edge A→B requires which inequality?
Q6If A* uses a heuristic that OVERESTIMATES at one state (h(n) > h*(n) for that n), which is the most accurate consequence?

Practice this in an interview

All questions
What is the difference between a biased estimator and an inconsistent estimator?

Bias measures the systematic error of an estimator at a fixed sample size — whether its expected value equals the true parameter. Consistency is an asymptotic property — whether the estimator converges in probability to the true parameter as sample size grows to infinity. An estimator can be biased yet consistent, or unbiased yet inconsistent.

When should you use grid search vs random search vs Bayesian optimisation for hyperparameter tuning?

Grid search exhaustively tries every combination in a predefined grid, which is only practical for 1–2 hyperparameters. Random search samples combinations uniformly at random and finds good values faster per compute budget, especially when only a few hyperparameters actually matter. Bayesian optimisation fits a surrogate model of the objective and proposes the next trial intelligently, giving the best sample efficiency for expensive evaluations.

Implement binary search correctly — and explain the off-by-one traps.

Binary search halves the search space each iteration to find a target in O(log n). The tricky part is not the idea but the boundary conditions: closed vs. half-open intervals, how to update lo/hi, and when to use lo < hi vs. lo <= hi. One clean template eliminates all the classic bugs.

What is p-hacking and how does multiple testing inflate false-positive rates?

P-hacking is the practice of making analytic choices — selecting metrics, segments, or time windows — after seeing data, guided by which choices produce p &lt; 0.05. Multiple testing means that even without intent, testing many hypotheses at alpha = 0.05 expects one false positive per 20 tests.

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Explore further

Related lessons

Skip to content