Informed (heuristic) search uses problem-specific knowledge beyond the problem definition to find solutions more efficiently than uninformed strategies.
The key idea: use a heuristic function h(n) to estimate the cost from node n to the goal.
A heuristic function h(n) estimates the cost of the cheapest path from node n to the goal.
Admissibility: h(n) never overestimates the actual cost to the goal.
h(n) ≤ h*(n) where h*(n) = true cost to goal
Consistency (Monotonicity): For every node n and successor n':
h(n) ≤ c(n, a, n') + h(n')
h_SLD = Straight-line distance to Bucharest
| City | h_SLD |
|---|---|
| Arad | 366 |
| Bucharest | 0 |
| Craiova | 160 |
| Fagaras | 176 |
| Sibiu | 253 |
| Zerind | 374 |
h_SLD is admissible because straight-line distance never overestimates road distance.
Expands the node that appears closest to the goal based on h(n).
1. Initialize priority queue with initial state
2. Evaluate f(n) = h(n) for each node
3. Expand node with MINIMUM h(n)
4. Repeat until goal found or failure
Arad → Sibiu (h=253) → Fagaras (h=176) → Bucharest (h=0) ✓
| Property | Value |
|---|---|
| Complete? | No (can get stuck in loops) |
| Optimal? | No |
| Time Complexity | O(b^m) |
| Space Complexity | O(b^m) |
Problem: Greedy search ignores the actual cost already paid — can lead to suboptimal paths.
Combines actual cost g(n) and heuristic estimate h(n):
f(n) = g(n) + h(n)
where:
g(n) = cost from start to n (actual)
h(n) = estimated cost from n to goal
f(n) = estimated total cost through n
1. Initialize priority queue with initial state, f = h(start)
2. Loop:
a. Pop node with MINIMUM f(n)
b. If GOAL → return solution
c. For each successor n':
g(n') = g(n) + step_cost
f(n') = g(n') + h(n')
Add n' to queue
Finding path from Arad to Bucharest:
| Step | Node | g(n) | h(n) | f(n) |
|---|---|---|---|---|
| 1 | Arad | 0 | 366 | 366 |
| 2 | Sibiu | 140 | 253 | 393 |
| 3 | Rimnicu | 220 | 193 | 413 |
| 4 | Fagaras | 239 | 176 | 415 |
| 5 | Pitesti | 317 | 100 | 417 |
| 6 | Bucharest | 418 | 0 | 418 |
Optimal path: Arad → Sibiu → Rimnicu → Pitesti → Bucharest (418 km)
| Property | Value |
|---|---|
| Complete? | Yes |
| Optimal? | Yes (if h is admissible) |
| Time Complexity | Exponential O(b^d) |
| Space Complexity | O(b^d) — keeps all nodes |
Theorem: If h(n) is admissible, A* is optimal.
Proof sketch:
| Aspect | Greedy Best-First | A* |
|---|---|---|
| Evaluation | f(n) = h(n) | f(n) = g(n) + h(n) |
| Complete | No | Yes |
| Optimal | No | Yes (admissible h) |
| Speed | Faster | Slower |
| Memory | Less | More |
A relaxed problem has fewer restrictions than the original. The optimal solution cost of a relaxed problem is an admissible heuristic.
Example — 8-puzzle:
Manhattan Distance:
h(n) = Σ |row_i - goal_row_i| + |col_i - goal_col_i|
Current State: Goal State:
7 2 4 1 2 3
5 0 6 4 5 6
8 3 1 7 8 0
Misplaced tiles h1 = 6 (tiles 7,2,5,6,8,3 are misplaced)
Manhattan distance h2:
tile 7: |2-2| + |0-1| = 1
tile 2: |0-0| + |1-1| = 0
tile 4: |0-0| + |2-2| = 0
tile 5: |1-1| + |0-0| = 0 (wait, 5 is at wrong position)
...
h2 = 18 (more accurate than h1)
h2 dominates h1: h2(n) ≥ h1(n) for all n → h2 is the better heuristic.
Short Answer (2 marks each)
Long Answer (8 marks each)
Think & Apply
S --1-- A --2-- G (h: S=5, A=3, G=0)
| |
3 1
| |
B ------2------ C (h: B=4, C=2)