Submit your answers as a .pdf or .docx file.
File name: <HọTên>_<MSSV>_W5_THEORY.pdf — e.g. NguyenVanAn_12345678_W5_THEORY.pdf
The directed weighted graph below is given. Each node shows its heuristic h(n) — the estimated remaining cost to reach Z. Numbers on edges are movement costs.
Find a path from S to Z using each algorithm below. Trace every step.
- A* — maintain an open list sorted by f(n) = g(n) + h(n)
- Greedy Best-First Search — always expand the node with the smallest h(n)
The directed weighted graph below has a left corridor and a right corridor. Each node shows h(n); edge numbers are movement costs.
Find a path from S to Z using each algorithm below. Trace every step.
- A*
- Hill Climbing (Steepest Ascent) — keep only the current node; move to a neighbour with strictly smaller h, or stop if none exists
During a dengue fever outbreak in the Mekong Delta, a vaccination team must deliver temperature-sensitive vaccines from the Provincial Cold-Chain Center to a Remote Commune Clinic cut off by seasonal flooding. Travel times (hours) account for road conditions, ferry waits, and flood detours.
- Provincial Cold-Chain Center → Phú Hòa Ferry (2h) · Hưng Long Bridge (5h) · Tân An Canal Road (3h)
- Phú Hòa Ferry → Bình Minh Market (3h) · Sông Hậu Crossing (6h)
- Hưng Long Bridge → Sông Hậu Crossing (2h) · Mỹ Phước Levee (4h)
- Tân An Canal Road → Mỹ Phước Levee (3h) · Long Khánh Dock (7h)
- Bình Minh Market → Trung Thành Elevated Road (4h)
- Sông Hậu Crossing → Trung Thành Elevated Road (2h) · Ngã Ba Đình Crossroads (5h)
- Mỹ Phước Levee → Ngã Ba Đình Crossroads (3h)
- Long Khánh Dock → Ngã Ba Đình Crossroads (2h)
- Trung Thành Elevated Road → Remote Commune Clinic (5h)
- Ngã Ba Đình Crossroads → Remote Commune Clinic (3h)
Heuristic h(n) — estimated direct boat travel time (hours) to the Clinic:
| Location | h(n) | Location | h(n) |
|---|---|---|---|
| Provincial Cold-Chain Center | 10 | Sông Hậu Crossing | 4 |
| Phú Hòa Ferry | 8 | Mỹ Phước Levee | 5 |
| Hưng Long Bridge | 6 | Long Khánh Dock | 4 |
| Tân An Canal Road | 7 | Trung Thành Elevated Road | 3 |
| Bình Minh Market | 6 | Ngã Ba Đình Crossroads | 2 |
| Remote Commune Clinic | 0 |
- Draw the state-space graph from the connection list above.
- Apply A* to find the fastest route. Trace step by step.
- Apply Greedy Best-First Search on the same graph. Trace step by step.
The directed weighted graph below has 8 nodes (S = start, G = goal). Each node shows its heuristic h(n); edge labels are movement costs.
A heuristic is admissible if and only if for every node n:
where h*(n) is the true optimal cost (shortest path cost) from n to G.
- Step 1. For each node S, A, B, C, D, E, F: find the shortest path to G and compute h*(n). Compare with the h(n) value shown in the graph.
- Step 2. Is h admissible overall? Identify every violation and state by how much h(n) overestimates h*(n).
- Step 3. If A* uses this heuristic as-is, is it still guaranteed to find the optimal path? Explain in one or two sentences.
- Step 4. Bonus — Propose the minimal correction that restores admissibility: change as few values as possible, by as small an amount as possible.
Use the same graph and heuristic values as Exercise 4.
A heuristic h is consistent if for every edge n → n' with cost c:
This is a local check — verify one edge at a time, without needing h*(n).
The table below lists every edge with the relevant h and cost values. For each row, compute c + h(n') and determine whether the condition holds.
| Edge | h(n) | Cost c | h(n') | c + h(n') = ? | Consistent? |
|---|---|---|---|---|---|
| S → A | 8 | 2 | 8 | ||
| S → B | 8 | 5 | 6 | ||
| A → C | 8 | 4 | 4 | ||
| A → D | 8 | 1 | 7 | ||
| B → D | 6 | 2 | 7 | ||
| B → E | 6 | 3 | 3 | ||
| C → F | 4 | 3 | 2 | ||
| D → F | 7 | 4 | 2 | ||
| D → E | 7 | 2 | 3 | ||
| E → G | 3 | 4 | 0 | ||
| F → G | 2 | 2 | 0 |
The 8-puzzle is a 3×3 sliding-tile board with tiles 1–8 and one blank. A move slides an adjacent tile into the blank. Goal state:
Count tiles not in their goal position (blank excluded).
Relaxed problem: each misplaced tile can teleport to its goal in one move.
Sum of horizontal + vertical distances of each tile from its goal (blank excluded).
Relaxed problem: tiles pass through each other freely, but still pay 1 per step.
For each state below, compute h₁ and h₂ by hand. Show the per-tile breakdown for each state.
A warehouse delivery robot starts at its charging station S = (0,0) and must reach the pickup zone G = (4,4). The floor is a 5 × 5 grid; the robot moves in four directions and each step costs 1. Gray cells are storage shelves (blocked).
Relaxed: robot flies in a straight line, ignoring shelves.
Relaxed: shelves are transparent — robot still pays 1 per step.
- Does h₂(2,4) change? Why or why not?
- Find h*(2,4) with the new wall. Is h₂ still admissible?
- What does this reveal about how obstacles affect the tightness of the Manhattan-distance heuristic?
A tourist arrives at Central Station and needs to reach the International Airport. The city metro has two lines and a shuttle service:
- Line 1 (Red Express): Central Station → Riverside → Midtown → Westgate → Airport
- Line 2 (Blue Local): Central Station → Uptown → Docklands → Eastfield → Skyview → (shuttle) → Airport
Transfer on foot at: Riverside ↔ Uptown, Midtown ↔ Docklands, Westgate ↔ Eastfield. All connections are one-directional.
Travel times (minutes)
| From | To | min | Service |
|---|---|---|---|
| Central Station | Riverside | 3 | Line 1 |
| Central Station | Uptown | 2 | Line 2 |
| Riverside | Midtown | 4 | Line 1 |
| Riverside | Uptown | 2 | Transfer |
| Midtown | Westgate | 3 | Line 1 |
| Midtown | Docklands | 3 | Transfer |
| Westgate | Airport | 2 | Line 1 |
| Westgate | Eastfield | 2 | Transfer |
| Uptown | Docklands | 3 | Line 2 |
| Docklands | Eastfield | 4 | Line 2 |
| Eastfield | Skyview | 2 | Line 2 |
| Skyview | Airport | 9 | Shuttle ⏳ |
Heuristic h(n) — straight-line distance to Airport (min)
| Station | h(n) |
|---|---|
| Central Station | 10 |
| Riverside | 8 |
| Midtown | 5 |
| Westgate | 2 |
| Uptown | 3 |
| Docklands | 3 |
| Eastfield | 2 |
| Skyview ★ | 1 |
| Airport | 0 |