Exercises — A - algorithm — heuristic, admissibility, consistency — important for GNC
We use the same three functions throughout, so let us restate them once in plain words before any symbol appears.
Level 1 — Recognition
L1.1 — Name the priority key
Three search algorithms use the same priority queue but different keys: Dijkstra, Greedy best-first, and A*. For each, write the key it minimises in terms of and .
Recall Solution
- Dijkstra's Algorithm pops smallest , i.e. key . It ignores the goal entirely.
- Greedy Best-First Search pops smallest , i.e. key . It ignores the road already paid for.
- A* pops smallest .
What this looks like: Dijkstra grows even, blind ripples; greedy dashes straight at the goal and can overpay; A* balances both.
L1.2 — Spot the definitions
Match each inequality to its name. (Here is the cost of the edge from to , as defined in the vocabulary box above.) (a) (b)
Recall Solution
(a) is admissibility — " never overestimates the true remaining cost." (b) is consistency (also called monotone) — the Triangle Inequality applied to the heuristic, holding for every edge with cost , plus .
L1.3 — What is at the start and goal?
Start node with . Goal node . What is ? What is (for a valid heuristic)?
Recall Solution
— we have paid nothing to reach the start. — a valid heuristic estimates zero remaining cost at the goal (this is part of the consistency definition and any sensible admissible heuristic satisfies it).
Level 2 — Application
L2.1 — Compute on a Manhattan grid
4-directional grid, every move costs . Heuristic Manhattan distance . Start , goal . Compute for the start and for the neighbour .
Recall Solution
Manhattan distance to goal :
- At : , , so .
- At (one step right, cost ): , , so .
The stays at — the away-from-goal neighbour would give , so A* ignores it.

Read the figure: the blue dot is the start (label ); the green arrow to keeps because every step toward the goal trades one unit of for one unit of — the total is unchanged, so A* happily advances. The red arrow to carries : stepping away raises by while still paying of , so its total jumps by . Because A* always pops the smallest , the red node sits at the back of the queue and is expanded only if nothing better remains — that is exactly the pruning that makes A* faster than Dijkstra's Algorithm.
L2.2 — Which nodes does A* pop first?
Open list holds three nodes with : , , . In what order does A* pop them?
Recall Solution
Compute : , , . A* pops smallest first → (4), then (5), then (6). Note has : it is a goal candidate, and since its is the smallest here, popping it returns an optimal-looking path — legitimate only if is admissible.
L2.3 — Verify admissibility of a scaled heuristic
On the same unit-cost grid, someone uses . Is admissible?
Recall Solution
Manhattan distance itself is admissible (). Halving it makes it even smaller: . So yes, admissible — but weaker, so A* will expand more nodes (closer to Dijkstra). Under-estimating is always safe for optimality; it just costs speed.
Level 3 — Analysis
L3.1 — Break optimality with a bad heuristic
Graph: (path cost ) and a direct edge . Set (true remaining is ), , . Trace A* and give the returned cost. Is it optimal?
Recall Solution
Expand (). Its successors go on the open list:
- : , , .
- (direct): , , .
Smallest is at , so A* pops the goal and returns cost . But the true optimum is . A* missed it because the inflated made the good path look expensive ().
Diagnosis: violates admissibility. Fix: clamp .

Read the figure: the two green arrows are the genuinely cheap route (total ), but node is tagged with the inflated , so its — the label deliberately shows the true remaining cost is only . The red arrow is the direct edge of cost ; with its . Since , A* pops the red goal first and never gets around to expanding . The picture makes the failure visible: an over-optimistic-looking number on the good path pushed it to the back of the queue.
L3.2 — Consistent ⇒ admissible, but not conversely
Give a heuristic that is admissible but not consistent on the graph . Use , (true , tight), .
Recall Solution
Admissible? True remaining: . We have , , . ✔ All admissible. Consistent? Check edge with : need . But . ✗ Violated. So this is admissible yet inconsistent — proving admissibility is the weaker property. Along this edge actually drops (, ), which is the tell-tale sign of inconsistency.
L3.3 — When A* re-expands a node
Consider this explicit graph with four nodes and directed edges:
- (a direct but expensive edge to ),
- ,
- (so the route reaches at total cost , cheaper than the direct ),
- .
Use the heuristic , , , and a large but still admissible (true remaining from is , so ✔ — admissible). Check consistency on edge , then trace A* and show it must re-open the closed node .
Recall Solution
Admissibility check. True remaining costs: (via ), , , . Our heuristic , , , . ✔ Admissible. Consistency check. Edge costs : need ✔, but edge costs : need , yet ✗. Inconsistent — this is the flaw that will cause the re-open.
Trace A*:
- Pop (). Push successors:
- via direct edge: , .
- : , .
- Smallest is (). Pop , close it with . Push its successor via : , . Now the open list has with (and the old with is superseded).
- Smallest now is (). Pop , close it with . Push : , .
- Pop , return cost — the true optimum . ✔
Where would the re-open show up? Swap the pop order that inconsistency permits: because is inflated, is larger than ? No — here , so is (luckily) popped first. To force the re-open we need closed via the expensive route before the cheap route is discovered. Give a genuinely large heuristic (now inadmissible, but the point is the mechanism):
- After popping : -direct has ; has .
- Now -direct () is popped first and closed with the wrong, expensive ; gets .
- Later is popped, discovers via the cheap route with . Since is already closed, A* must re-open , update , and re-propagate to ().
The clean, admissible-only re-open. Keep (admissible) but make the direct edge look better by lowering it slightly: set instead of . Then after : -direct , . Pop -direct first, close with . Pop (), discover via with — a tie, no improvement, no re-open here. The reliable lesson is the general principle below; constructing a minimal admissible-only re-open requires the cheap route's to strictly beat the closed , which needs the closed node's first route to have been mis-ranked by an inconsistent (yet still admissible) elsewhere on the frontier.
The principle that always holds. With consistency, never decreases along an expansion, so a node's is final the moment it is popped — never re-opened. Without consistency (even if still admissible), can dip, so a node closed via a worse-looking route may later gain a strictly cheaper path and must be re-opened and re-propagated. This is extra work, never a loss of optimality — admissibility still guarantees the shortest path (L5.2), consistency merely removes the re-work.
Level 4 — Synthesis
L4.1 — Prove Euclidean distance is consistent
Continuous plane, cost of an edge = its Euclidean length. Heuristic straight-line distance from to goal. Prove is consistent.
Recall Solution
Let be points and the goal. Consistency needs , i.e. This is exactly the Triangle Inequality for straight-line distances (a straight path from to can never be longer than detouring through ). It holds for all . And . Both consistency conditions met. ✔ Since consistency ⟹ admissibility, the Euclidean heuristic is also admissible — the guarantee GNC Path Planning relies on.
L4.2 — Design an admissible heuristic for diagonal moves
Grid where you may move in 8 directions: orthogonal step costs , diagonal step costs . Propose an admissible heuristic and justify it. (This is the octile setting.)
Recall Solution
Let , . The cheapest route uses as many diagonal steps as possible (each knocks down both and by ), then straight steps for the leftover. The exact minimum on an empty grid is the octile distance:
- Admissible? With no obstacles this equals , so always (obstacles only make the true path longer). ✔
- Consistent? It equals a true shortest-path metric on the empty grid, which obeys the triangle inequality, so consistent. ✔
- Why not Manhattan here? Manhattan would overestimate because it forbids the cheaper diagonal — that could break admissibility (it counts where a diagonal costs only ). So plain Manhattan is the wrong tool for 8-connected grids.
Numeric check for :
L4.3 — Weighted A* trade-off
Weighted A* and Bounded Suboptimality uses with . On the L2.1 grid with Manhattan and , recompute at and , and state the guarantee you lose and what you gain.
Recall Solution
With :
- : .
- : . The inflated pulls harder toward the goal, so the goalward node now has a strictly smaller (), sharpening the search. You gain speed (fewer expansions). You lose exact optimality, but you keep a bound: the returned path costs at most the optimum. Here means "never worse than double optimal." This is a deliberate, controlled inadmissibility — not a bug.
Level 5 — Mastery
L5.1 — A* with
What algorithm is A* when for all ? Is admissible? Consistent?
Recall Solution
With , , so A* pops smallest first — it is exactly Dijkstra's Algorithm.
- Admissible? always (true cost is never negative, because all edge costs ). ✔
- Consistent? since edge costs are non-negative, and . ✔ So is a perfectly valid heuristic — just totally unguided. A* with is not broken, merely blind.
L5.2 — Prove admissibility ⇒ the first popped goal is optimal
Reconstruct the optimality proof: assume admissible, and show A* cannot return a suboptimal goal.
Recall Solution
Let be the true optimal cost. Suppose, for contradiction, A* is about to pop a goal with .
- A frontier node sits on an optimal path. Take any optimal path from start to goal. Not all of it is expanded yet (else the optimal goal would already be popped). So some node on this optimal path is currently on the open list — call it the boundary node.
- Bound . Because lies on an optimal path, its true optimal total is (the cost to reach optimally plus the optimal remainder). Apply admissibility :
- Bound . is a goal, so , giving .
- Chain the two. Combining steps 2 and 3: .
- Contradiction. A* always pops the smallest first, so the frontier node (with ) would be popped before (with ). Hence A* cannot pop the suboptimal first.
Therefore the first goal A* removes from the queue has cost , and since is optimal it equals : the returned path is optimal. ∎ This mirrors Bellman Optimality: the optimal cost decomposes as cost-so-far plus optimal cost-to-go ( on an optimal path), and admissibility keeps the estimate on the safe side of that decomposition.
L5.3 — Design and fully defend a heuristic for a drone corridor (GNC)
A drone flies in a plane, cost = Euclidean length, but a circular no-fly zone sits between start and goal. Someone proposes straight-line distance ignoring the no-fly zone. Is it still admissible? Is it consistent? Would you use it?
Recall Solution
- Admissible? The straight-line distance ignoring the obstacle is any real flyable path length (the real path must detour around the zone, so it can only be longer). Thus . ✔ Admissible.
- Consistent? Straight-line distance satisfies the triangle inequality for all points (L4.1), independent of obstacles, and . ✔ Consistent.
- Use it? Yes. It is optimistic (never overestimates), so A* stays optimal, and it still pulls the search toward the goal, exploring a narrow cone — exactly what limited on-board compute in GNC Path Planning wants. Ignoring the obstacle in the heuristic is fine; the obstacle is enforced by the graph's edges (you simply cannot traverse into the zone), not by the heuristic.
Sanity number: if start , goal , straight-line ; any obstacle-avoiding path is , so holds. (For a zone forcing a detour, say a semicircular arc of radius , the true path is — strictly longer, confirming the estimate under-shoots.)