Skip to main content

Unit 4: Question Bank & Model Answers

Course - Fundamentals of AI
Unit - Unit 4: Informed Search, Adversarial Search and Constraint Satisfaction Problems


Question 1: Travelling Salesman Problem (Search Formulation & Heuristics)​

info

Question Statement

A salesman starts at city AA, visits BB, CC, and DD once each, and returns to AA. The distances are:

  • AB=2AB = 2
  • AC=3AC = 3
  • AD=9AD = 9
  • BC=4BC = 4
  • BD=7BD = 7
  • CD=5CD = 5

Sub-questions:

  1. Formulate TSP as a search problem: states, initial state, actions, goal test and path cost.
  2. List every distinct tour and find the optimal one.
  3. Apply the nearest-neighbour heuristic from AA. Is its tour optimal?
  4. The number of distinct tours is (n−1)!/2(n - 1)! / 2. Calculate it for 1010 and 2020 cities and explain why exhaustive search is impractical.

Model Answer​

1. Problem Formulation​

  • States: Sequence of visited cities ending at the current city: ([c1,c2,…,ck],ck)([c_1, c_2, \dots, c_k], c_k).
  • Initial State: ([A],A)([A], A)
  • Actions: Visit any remaining unvisited city: ACTIONS(s)={c∈{B,C,D}∖visited(s)}\text{ACTIONS}(s) = \{c \in \{B, C, D\} \setminus \text{visited}(s)\}. If all cities are visited, the only action is returning to AA.
  • Goal Test: All cities {A,B,C,D}\{A, B, C, D\} are visited exactly once and the tour has returned to AA (tour length =5= 5 cities).
  • Path Cost: Sum of Euclidean/edge distances along the tour: ∑i=1ndist(ci,ci+1)where cn+1=c1=A\sum_{i=1}^{n} \text{dist}(c_i, c_{i+1}) \quad \text{where } c_{n+1} = c_1 = A

2. Distinct Tours & Optimal Tour​

For n=4n = 4 cities, the number of distinct undirected tours is (4−1)!2=3!2=3\frac{(4-1)!}{2} = \frac{3!}{2} = 3:

Tour #Tour SequenceEdge Cost CalculationTotal Cost
1A−B−C−D−AA - B - C - D - AAB+BC+CD+DA=2+4+5+9AB + BC + CD + DA = 2 + 4 + 5 + 92020
2A−B−D−C−AA - B - D - C - AAB+BD+DC+CA=2+7+5+3AB + BD + DC + CA = 2 + 7 + 5 + 317\mathbf{17}
3A−C−B−D−AA - C - B - D - AAC+CB+BD+DA=3+4+7+9AC + CB + BD + DA = 3 + 4 + 7 + 92323
  • Optimal Tour: A→B→D→C→A\mathbf{A \to B \to D \to C \to A} (or reverse) with Cost = 17.

3. Nearest-Neighbour (NN) Heuristic from AA​

  • Step 1: From AA, unvisited are {B(2),C(3),D(9)}\{B (2), C (3), D (9)\}. Choose nearest: B\mathbf{B} (cost 22).
  • Step 2: From BB, unvisited are {C(4),D(7)}\{C (4), D (7)\}. Choose nearest: C\mathbf{C} (cost 44).
  • Step 3: From CC, unvisited is {D(5)}\{D (5)\}. Choose remaining: D\mathbf{D} (cost 55).
  • Step 4: From DD, return to start city: A\mathbf{A} (cost 99).
  • NN Tour Generated: A→B→C→D→AA \to B \to C \to D \to A, Cost =2+4+5+9=20= 2 + 4 + 5 + 9 = \mathbf{20}.
  • Is it optimal? NO. The optimal tour is 1717. NN's greedy local decision early (B→CB \to C) forces the expensive return edge D→A=9D \to A = 9.

4. Combinatorial Explosion (n=10,20n = 10, 20)​

  • For n=10n = 10 cities: (10−1)!2=9!2=362,8802=181,440 tours\frac{(10 - 1)!}{2} = \frac{9!}{2} = \frac{362,880}{2} = \mathbf{181,440} \text{ tours}
  • For n=20n = 20 cities: (20−1)!2=19!2=1.216×10172≈6.08×1016 tours\frac{(20 - 1)!}{2} = \frac{19!}{2} = \frac{1.216 \times 10^{17}}{2} \approx \mathbf{6.08 \times 10^{16}} \text{ tours}
  • Why exhaustive search is impractical:
    TSP is NP-hard with O(n!)O(n!) factorial complexity. At 1 billion (10910^9) tour evaluations per second, checking all tours for n=20n=20 takes: 6.08×1016109 sec≈6.08×107 seconds≈1.93 years\frac{6.08 \times 10^{16}}{10^9 \text{ sec}} \approx 6.08 \times 10^7 \text{ seconds} \approx \mathbf{1.93 \text{ years}}

Question 2: Graph Colouring with Forward Checking and MRV​

info

Question Statement

Six districts P,Q,R,S,T,UP, Q, R, S, T, U must be coloured Red, Green or Blue so that neighbours differ. The adjacent pairs are:

  • P−QP - Q
  • P−RP - R
  • Q−RQ - R
  • Q−SQ - S
  • R−SR - S
  • R−TR - T
  • S−TS - T
  • S−US - U
  • T−UT - U

Sub-questions:

  1. State the CSP's three components and draw the constraint graph.
  2. Solve it with backtracking plus forward checking, using the alphabetical variable order and the value order Red, Green, Blue. Show the domain table after every assignment.
  3. Which variable would the degree heuristic pick first, and why? Show how MRV then guides the remaining choices.

Model Answer​

1. CSP Components & Constraint Graph​

  • Variables (XX): {P,Q,R,S,T,U}\{P, Q, R, S, T, U\}
  • Domains (DD): Di={Red (R),Green (G),Blue (B)}D_i = \{\text{Red (R)}, \text{Green (G)}, \text{Blue (B)}\} for all variables.
  • Constraints (CC): c(u)≠c(v)c(u) \neq c(v) for all adjacent pairs (u,v)∈E(u, v) \in E.

2. Backtracking with Forward Checking Trace​

Variable order: P,Q,R,S,T,UP, Q, R, S, T, U | Value order: R,G,BR, G, B

StepAssignmentD(P)D(P)D(Q)D(Q)D(R)D(R)D(S)D(S)D(T)D(T)D(U)D(U)Forward Checking Action
0Initial{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}All domains full.
1P=RP = R{R}\{R\}{G,B}\{G, B\}{G,B}\{G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}Remove RR from neighbors Q,RQ, R.
2Q=GQ = G{R}\{R\}{G}\{G\}{B}\{B\}{R,B}\{R, B\}{R,G,B}\{R, G, B\}{R,G,B}\{R, G, B\}Remove GG from neighbors R,SR, S.
3R=BR = B{R}\{R\}{G}\{G\}{B}\{B\}{R}\{R\}{R,G}\{R, G\}{R,G,B}\{R, G, B\}Remove BB from neighbors S,TS, T.
4S=RS = R{R}\{R\}{G}\{G\}{B}\{B\}{R}\{R\}{G}\{G\}{G,B}\{G, B\}Remove RR from neighbors T,UT, U.
5T=GT = G{R}\{R\}{G}\{G\}{B}\{B\}{R}\{R\}{G}\{G\}{B}\{B\}Remove GG from neighbor UU.
6U=BU = B{R}\{R\}{G}\{G\}{B}\{B\}{R}\{R\}{G}\{G\}{B}\{B\}Assign remaining forced value.
  • Final Valid Coloring:
    P=Red,Q=Green,R=Blue,S=Red,T=Green,U=Blue\mathbf{P = \text{Red}, \quad Q = \text{Green}, \quad R = \text{Blue}, \quad S = \text{Red}, \quad T = \text{Green}, \quad U = \text{Blue}}

3. Degree Heuristic & MRV Guidance​

  • Degree Heuristic First Pick:
    • Degrees: P(2),Q(3),R(4),S(4),T(3),U(2)P(2), Q(3), R(4), S(4), T(3), U(2).
    • RR and SS tie with degree 4 (most constraining on remaining unassigned variables).
    • Alphabetical tie-breaker selects RR first.
    • Why: Picking the highest-degree variable constrains the maximum number of neighbors early, reducing future branching factor.
  • MRV Guidance for Remaining Choices:
    • Once RR is assigned a color (e.g., R=RedR = \text{Red}), forward checking reduces the domains of P,Q,S,TP, Q, S, T to 2 values ({G,B}\{G, B\}).
    • Minimum Remaining Values (MRV) selects the variable with the fewest legal values (e.g., picking SS or QQ).
    • As soon as any variable domain shrinks to a singleton (11 value left), MRV immediately selects it next (fail-first principle), eliminating search branching.

Question 3: Cryptarithmetic as a CSP​

info

Question Statement

T O
+ G O
-----
O U T
TO+GOOUT\begin{array}{ccc} & \text{T} & \text{O} \\ + & \text{G} & \text{O} \\ \hline \text{O} & \text{U} & \text{T} \end{array}
  1. Write the variables (including carries), domains, the all-different constraint and the column constraints.
  2. Solve the puzzle step by step. Justify the value of each letter from the constraints.
  3. Verify the answer.

Model Answer​

1. CSP Formalization​

  • Variables: Letters V={T,O,G,U}V = \{T, O, G, U\}; Carries C={C1,C2}C = \{C_1, C_2\} (where C1C_1 is units carry, C2C_2 is tens carry).
  • Domains:
    • D(O),D(T),D(G)∈{1,2,…,9}D(O), D(T), D(G) \in \{1, 2, \dots, 9\} (leading digits cannot be 0).
    • D(U)∈{0,1,2,…,9}D(U) \in \{0, 1, 2, \dots, 9\}
    • D(C1),D(C2)∈{0,1}D(C_1), D(C_2) \in \{0, 1\}
  • Global Constraint: Alldiff(T,O,G,U)\text{Alldiff}(T, O, G, U)
  • Column Constraints:
    1. Units: O+O=T+10⋅C1O + O = T + 10 \cdot C_1
    2. Tens: T+G+C1=U+10⋅C2T + G + C_1 = U + 10 \cdot C_2
    3. Hundreds: C2=OC_2 = O

2. Step-by-Step Deduction​

  1. Hundreds Column →O\to O and C2C_2:
    • The sum of two 2-digit numbers is at most 99+99=198  ⟹  C2≤199 + 99 = 198 \implies C_2 \le 1.
    • Since OO is a leading digit, O≠0  ⟹  C2=1O \neq 0 \implies \mathbf{C_2 = 1} and O=1\mathbf{O = 1}.
  2. Units Column →T\to T and C1C_1:
    • Substitute O=1O = 1: 1+1=T+10⋅C1  ⟹  2=T+10⋅C11 + 1 = T + 10 \cdot C_1 \implies 2 = T + 10 \cdot C_1.
    • Since 2<102 < 10, carry C1=0\mathbf{C_1 = 0} and T=2\mathbf{T = 2}.
  3. Tens Column →G\to G and UU:
    • Substitute T=2,C1=0,C2=1T = 2, C_1 = 0, C_2 = 1: 2+G+0=U+10  ⟹  G−U=82 + G + 0 = U + 10 \implies G - U = 8
    • Possible single-digit pairs (G,U)(G, U) where G≤9G \le 9:
      • Case 1: (9,1)  ⟹  (9, 1) \implies invalid because O=1O = 1 (violates Alldiff\text{Alldiff}).
      • Case 2: (8,0)  ⟹  (8, 0) \implies valid because 88 and 00 are distinct from O=1,T=2O=1, T=2.
    • Therefore: G=8\mathbf{G = 8} and U=0\mathbf{U = 0}.

3. Verification​

  • Assigned Digits: T=2,O=1,G=8,U=0T = 2, O = 1, G = 8, U = 0
  • Alldiff Check: {2,1,8,0}\{2, 1, 8, 0\} are all distinct ✓\checkmark
  • Leading Digit Check: T≠0,G≠0,O≠0✓T \neq 0, G \neq 0, O \neq 0 \checkmark
  • Arithmetic Check: 21+81=102(TO+GO=OUT)✓21 + 81 = 102 \quad (\text{TO} + \text{GO} = \text{OUT}) \quad \checkmark

Question 4: Exam Scheduling as a CSP​

info

Question Statement

Five exams (AI, DBMS, CN, OS, Maths) must be placed in three slots {Mon,Tue,Wed}\{\text{Mon}, \text{Tue}, \text{Wed}\}. Two exams cannot share a slot if any student takes both. The pairs that share students are:

  • AI−DBMS\text{AI} - \text{DBMS}
  • AI−CN\text{AI} - \text{CN}
  • DBMS−CN\text{DBMS} - \text{CN}
  • CN−OS\text{CN} - \text{OS}
  • DBMS−OS\text{DBMS} - \text{OS}
  • OS−Maths\text{OS} - \text{Maths}
  • AI−Maths\text{AI} - \text{Maths}
  • CN−Maths\text{CN} - \text{Maths}

The Maths examiner is unavailable on Tuesday. The department would also prefer AI not to be on Monday.

Sub-questions:

  1. Formulate this as a CSP and draw the constraint graph. Classify each constraint as unary or binary, and as hard or soft.
  2. Solve it with plain backtracking, using the variable order AI, DBMS, CN, OS, Maths and the value order Mon, Tue, Wed. Show the search tree, including every dead end and backtrack.
  3. Does your solution satisfy the soft constraint? If not, give a schedule that meets all hard constraints and the soft one.

Model Answer​

1. CSP Formulation & Constraint Classification​

  • Variables: X={AI,DBMS,CN,OS,Maths}X = \{\text{AI}, \text{DBMS}, \text{CN}, \text{OS}, \text{Maths}\}
  • Domains: Di={Mon,Tue,Wed}D_i = \{\text{Mon}, \text{Tue}, \text{Wed}\} for all variables.
  • Constraint Classification:
    • Unary Hard Constraint: Maths≠Tue\text{Maths} \neq \text{Tue} (examiner unavailable).
    • Unary Soft Constraint: AI≠Mon\text{AI} \neq \text{Mon} (department preference).
    • Binary Hard Constraints: Mutual exclusion between shared-student pairs: AI≠DBMS,  AI≠CN,  DBMS≠CN,  CN≠OS,  DBMS≠OS,  OS≠Maths,  AI≠Maths,  CN≠Maths\text{AI} \neq \text{DBMS}, \; \text{AI} \neq \text{CN}, \; \text{DBMS} \neq \text{CN}, \; \text{CN} \neq \text{OS}, \; \text{DBMS} \neq \text{OS}, \; \text{OS} \neq \text{Maths}, \; \text{AI} \neq \text{Maths}, \; \text{CN} \neq \text{Maths}

2. Plain Backtracking Search Trace​

Order: AI, DBMS, CN, OS, Maths | Values: Mon, Tue, Wed

  1. AI = Mon
  2. DBMS: Mon conflicts with AI →\to DBMS = Tue
  3. CN: Mon conflicts with AI, Tue conflicts with DBMS →\to CN = Wed
  4. OS: Mon has no conflicts with DBMS(Tue) or CN(Wed) →\to OS = Mon
  5. Maths:
    • Mon conflicts with OS(Mon) & AI(Mon) →\to Dead end.
    • Tue violates unary hard constraint (Maths≠Tue\text{Maths} \neq \text{Tue}) →\to Dead end.
    • Wed conflicts with CN(Wed) →\to Dead end.
    • Backtrack from Maths!
  6. OS: Try Tue (conflicts with DBMS) →\to Try Wed (conflicts with CN) →\to Backtrack OS!
  7. CN: No more values →\to Backtrack CN!
  8. DBMS: Try Wed →\to CN(Tue) →\to OS(Mon) →\to Maths has no valid slot →\to Backtrack DBMS!
  9. AI: Backtrack to AI →\to AI = Tue
  10. DBMS = Mon (valid)
  11. CN = Wed (valid: Mon conflicts with DBMS, Tue conflicts with AI)
  12. OS = Tue (valid: Mon conflicts with DBMS, Wed conflicts with CN; AI-OS has no conflict)
  13. Maths = Mon (valid: Tue unavailable; Wed conflicts with CN; OS is Tue, AI is Tue, CN is Wed   ⟹  \implies no conflict with Mon!)
  • Search Tree Result: AI=Tue,DBMS=Mon,CN=Wed,OS=Tue,Maths=Mon\mathbf{\text{AI} = \text{Tue}, \quad \text{DBMS} = \text{Mon}, \quad \text{CN} = \text{Wed}, \quad \text{OS} = \text{Tue}, \quad \text{Maths} = \text{Mon}}

3. Soft Constraint Evaluation​

  • Does the solution satisfy the soft constraint?
    YES. The solution assigns AI=Tue\text{AI} = \text{Tue}, which perfectly satisfies the soft preference (AI≠Mon\text{AI} \neq \text{Mon}).
  • Final Schedule by Slot:
    • Monday: DBMS, Maths
    • Tuesday: AI, OS
    • Wednesday: CN

Question 5: Minimax and Alpha-Beta Pruning on a Three-Ply Tree​

info

Question Statement

AA is the MAX root with MIN children B,C,DB, C, D. Each MIN node has two MAX children, and each MAX child has two leaves. Leaf values, left to right, are:

MIN NodeFirst MAX Child LeavesSecond MAX Child Leaves
B8, 79, 3
C2, 49, 8
D1, 68, 9

Sub-questions:

  1. Draw the tree and compute the minimax value of every node. Which move does MAX choose at AA?
  2. Apply alpha-beta pruning left to right, showing α\alpha and β\beta at every node. List the pruned leaves, and state how many of the 12 leaves are evaluated.
  3. Does alpha-beta ever change the value at the root? Justify.

Model Answer​

1. Minimax Values & Optimal Move​

  • Level 3 (MAX Children):
    • B1=max⁡(8,7)=8,B2=max⁡(9,3)=9B_1 = \max(8, 7) = \mathbf{8}, \quad B_2 = \max(9, 3) = \mathbf{9}
    • C1=max⁡(2,4)=4,C2=max⁡(9,8)=9C_1 = \max(2, 4) = \mathbf{4}, \quad C_2 = \max(9, 8) = \mathbf{9}
    • D1=max⁡(1,6)=6,D2=max⁡(8,9)=9D_1 = \max(1, 6) = \mathbf{6}, \quad D_2 = \max(8, 9) = \mathbf{9}
  • Level 2 (MIN Children):
    • B=min⁡(B1,B2)=min⁡(8,9)=8B = \min(B_1, B_2) = \min(8, 9) = \mathbf{8}
    • C=min⁡(C1,C2)=min⁡(4,9)=4C = \min(C_1, C_2) = \min(4, 9) = \mathbf{4}
    • D=min⁡(D1,D2)=min⁡(6,9)=6D = \min(D_1, D_2) = \min(6, 9) = \mathbf{6}
  • Level 1 (MAX Root AA):
    • A=max⁡(B,C,D)=max⁡(8,4,6)=8A = \max(B, C, D) = \max(8, 4, 6) = \mathbf{8}
  • Move Chosen by MAX at AA: Move to BB (yields the maximum guaranteed payoff of 8).

2. Alpha-Beta Pruning Trace (Left to Right)​

Initial root bounds: α=−∞,β=+∞\alpha = -\infty, \beta = +\infty

  1. Subtree under BB:
    • B1B_1: Evaluates 8  ⟹  α=88 \implies \alpha = 8. Evaluates 7  ⟹  B1=87 \implies B_1 = 8.
    • At MIN node BB: β=min⁡(+∞,8)=8\beta = \min(+\infty, 8) = 8. Bounds: [α=−∞,β=8][\alpha = -\infty, \beta = 8].
    • B2B_2: Evaluates leaf 9  ⟹  α=max⁡(−∞,9)=99 \implies \alpha = \max(-\infty, 9) = 9.
    • Pruning condition: α≥β\alpha \ge \beta (9≥89 \ge 8). Leaf 3 is PRUNED.
    • BB returns 88. Root AA updates α=max⁡(−∞,8)=8\alpha = \max(-\infty, 8) = \mathbf{8}.
  2. Subtree under CC (bounds [α=8,β=+∞][\alpha = 8, \beta = +\infty]):
    • C1C_1: Evaluates 2,4  ⟹  C1=42, 4 \implies C_1 = 4.
    • At MIN node CC: β=min⁡(+∞,4)=4\beta = \min(+\infty, 4) = 4.
    • Pruning condition: α≥β\alpha \ge \beta (8≥48 \ge 4).
      Subtree C2C_2 (Leaves 9 and 8) is PRUNED.
  3. Subtree under DD (bounds [α=8,β=+∞][\alpha = 8, \beta = +\infty]):
    • D1D_1: Evaluates 1,6  ⟹  D1=61, 6 \implies D_1 = 6.
    • At MIN node DD: β=min⁡(+∞,6)=6\beta = \min(+\infty, 6) = 6.
    • Pruning condition: α≥β\alpha \ge \beta (8≥68 \ge 6).
      Subtree D2D_2 (Leaves 8 and 9) is PRUNED.
  • Pruned Leaves (5 leaves): 33 (under B2B_2), 9,89, 8 (under C2C_2), and 8,98, 9 (under D2D_2).
  • Evaluated Leaves (7 leaves): {8,7,9,2,4,1,6}\{8, 7, 9, 2, 4, 1, 6\} (7 out of 12 evaluated).

3. Root Invariance Proof​

  • Does Alpha-Beta ever alter the root value? NO.
  • Justification: Alpha-Beta is mathematically exact. A branch is pruned only when α≥β\alpha \ge \beta, proving that the branch contains a value strictly worse than an already examined alternative for one of the players. Pruned branches can never influence the minimax decision at the root.

Question 6: AND-OR Graph and AO* Algorithm​

info

Question Statement

Consider the AND-OR graph below. Every arc costs 11. In an AND arc, all the connected children must be solved.

NodeSuccessorsHeuristic hh of Successors
A (start)OR arc to BB; AND arc to (C,D)(C, D)h(B)=5h(B) = 5, h(C)=2h(C) = 2, h(D)=3h(D) = 3
BOR arc to EE; OR arc to FFh(E)=6h(E) = 6, h(F)=8h(F) = 8
CAND arc to (G,H)(G, H)h(G)=1h(G) = 1, h(H)=1h(H) = 1

Sub-questions:

  1. Draw the AND-OR graph.
  2. Trace AO* for three expansions (AA, then the best node, then the next best). After each expansion, show the revised costs propagated back to AA and mark the current best partial solution graph.
  3. Why can't A* be applied directly to this problem? State the main difference in how AO* handles it.

Model Answer​

1. AND-OR Graph Representation​


2. AO* Three-Expansion Trace​

Cost formulas: f(OR)=c+h(n)f(\text{OR}) = c + h(n); f(AND)=c+∑h(ni)f(\text{AND}) = c + \sum h(n_i), with c=1c = 1.

Expansion 1: Expand Node AA​
  • Branch 1 (OR to BB): f(B)=1+h(B)=1+5=6f(B) = 1 + h(B) = 1 + 5 = 6
  • Branch 2 (AND to (C,D)(C, D)): f(C,D)=1+h(C)+h(D)=1+2+3=6f(C, D) = 1 + h(C) + h(D) = 1 + 2 + 3 = 6
  • Tie-breaker: Select AND branch (C,D)(C, D).
  • Cost at AA: h(A)=6h(A) = 6.
  • Best Partial Solution Graph: A→(C,D)A \to (C, D).
Expansion 2: Expand Node CC​
  • CC has AND arc to (G,H)(G, H): f(G,H)=1+h(G)+h(H)=1+1+1=3  ⟹  h(C)=3f(G, H) = 1 + h(G) + h(H) = 1 + 1 + 1 = 3 \implies h(C) = 3
  • Backpropagate to AA:
    • Cost of branch (C,D)=1+h(C)+h(D)=1+3+3=7(C, D) = 1 + h(C) + h(D) = 1 + 3 + 3 = \mathbf{7}
    • Cost of branch B=1+h(B)=1+5=6B = 1 + h(B) = 1 + 5 = \mathbf{6}
  • Best branch switches to OR to BB (6<76 < 7).
  • Cost at AA: h(A)=6h(A) = 6.
  • Best Partial Solution Graph: A→BA \to B.
Expansion 3: Expand Node BB​
  • Branch to EE: f(E)=1+h(E)=1+6=7f(E) = 1 + h(E) = 1 + 6 = 7
  • Branch to FF: f(F)=1+h(F)=1+8=9f(F) = 1 + h(F) = 1 + 8 = 9
  • Best choice at BB is E  ⟹  h(B)=7E \implies h(B) = 7.
  • Backpropagate to AA:
    • Cost of branch B=1+h(B)=1+7=8B = 1 + h(B) = 1 + 7 = \mathbf{8}
    • Cost of branch (C,D)=1+h(C)+h(D)=1+3+3=7(C, D) = 1 + h(C) + h(D) = 1 + 3 + 3 = \mathbf{7}
  • Best branch switches back to (C,D)(C, D) (7<87 < 8).
  • Cost at AA: h(A)=7h(A) = 7.
  • Best Partial Solution Graph: A→(C,D)A \to (C, D) with C→(G,H)C \to (G, H).

3. Why A∗A^* Fails & Key Difference in AO*​

  • Why A∗A^* cannot be applied: A∗A^* assumes every action leads to a single successor and outputs a single linear path. In an AND-OR graph, AND branches represent problem decomposition where all subproblems must be solved, requiring a solution tree, not a path.
  • Main Difference in AO*: AO* operates directly on partial solution trees. Whenever node costs are updated, AO* propagates revised estimates up to the root, dynamically switching connectors and re-routing the optimal partial tree.

info

Question Statement

A delivery robot must travel from start SS to goal GG. Edge costs and heuristic values h(n)h(n) are given below:

Edge Costs:

EdgeCost
S−AS - A2
S−BS - B6
A−CA - C2
A−DA - D4
B−GB - G6
C−GC - G3
D−GD - G2

Heuristic Values h(n)h(n):

NodeSSAABBCCDDGG
h(n)h(n)652320

Sub-questions:

  1. Trace Greedy best-first search from SS. Give the path found and its cost.
  2. Trace A* search, showing g(n)g(n), h(n)h(n) and f(n)f(n) for every node placed on the open list. Give the path found and its cost.
  3. Suppose h(C)h(C) is changed from 33 to 66. Is hh still admissible? Re-run A* and explain how the path and its cost change.

Model Answer​

1. Greedy Best-First Search Trace​

Orders nodes strictly by h(n)h(n):

StepPop Nodeh(n)h(n)Generated Neighbors & hhOpen List [Node,h][Node, h]
0——Start{[S,6]}\{ [S, 6] \}
1SS66A(h=5),B(h=2)A (h=5), B (h=2){[B,2],[A,5]}\{ [B, 2], [A, 5] \}
2BB22G(h=0)G (h=0){[G,0],[A,5]}\{ [G, 0], [A, 5] \}
3GG00Goal reached—
  • Greedy Path: S→B→G\mathbf{S \to B \to G}
  • Path Cost: c(S−B)+c(B−G)=6+6=12c(S-B) + c(B-G) = 6 + 6 = \mathbf{12}

2. A* Search Trace (f(n)=g(n)+h(n)f(n) = g(n) + h(n))​

StepPop NodegghhffGenerated NeighborsOpen List [Node,g,h,f,Path][Node, g, h, f, Path]
0————Start{[S,0,6,6,S]}\{ [S, 0, 6, 6, S] \}
1SS006666A:g=2,f=2+5=7A: g=2, f=2+5=7
B:g=6,f=6+2=8B: g=6, f=6+2=8
{[A,2,5,7,S→A],[B,6,2,8,S→B]}\{ [A, 2, 5, 7, S \to A], [B, 6, 2, 8, S \to B] \}
2AA225577C:g=4,f=4+3=7C: g=4, f=4+3=7
D:g=6,f=6+2=8D: g=6, f=6+2=8
{[C,4,3,7,S→A→C],[B,6,2,8],[D,6,2,8]}\{ [C, 4, 3, 7, S \to A \to C], [B, 6, 2, 8], [D, 6, 2, 8] \}
3CC443377G:g=7,f=7+0=7G: g=7, f=7+0=7{[G,7,0,7,S→A→C→G],[B,8],[D,8]}\{ [G, 7, 0, 7, S \to A \to C \to G], [B, 8], [D, 8] \}
4GG770077Goal popped on expansion—
  • Optimal Path: S→A→C→G\mathbf{S \to A \to C \to G}
  • Optimal Cost: 2+2+3=72 + 2 + 3 = \mathbf{7}

3. Heuristic Modification (h(C)=6h(C) = 6)​

  • Admissibility Check:
    • True remaining shortest cost: h∗(C)=c(C−G)=3h^*(C) = c(C-G) = 3.
    • Condition: h(n)≤h∗(n)h(n) \le h^*(n).
    • Since h(C)=6>h∗(C)=3h(C) = 6 > h^*(C) = 3, hh is NO LONGER ADMISSIBLE (it overestimates).
  • Re-running A* with h(C)=6h(C) = 6:
    • At Step 2, CC has f(C)=g(C)+h(C)=4+6=10f(C) = g(C) + h(C) = 4 + 6 = \mathbf{10}.
    • Open list becomes: {[B,f=8],[D,f=8],[C,f=10]}\{ [B, f=8], [D, f=8], [C, f=10] \}.
    • BB and DD are expanded before CC.
    • DD reaches GG with cost g(G)=6+2=8,f=8g(G) = 6 + 2 = 8, f = 8.
    • Goal GG is popped via DD with f=8f = 8 (before CC with f=10f = 10 is ever expanded).
  • New Path Found: S→A→D→G\mathbf{S \to A \to D \to G} with Cost = 8.
  • Impact: Overestimating h(C)h(C) misleads A∗A^* into abandoning the optimal path (cost 77) in favor of a suboptimal path (cost 88).

info

Question Statement

Consider the search tree below. AA is the start node and KK is the goal. Children are generated left to right in alphabetical order:

NodeChildren
AB,CB, C
BD,ED, E
CF,GF, G
DH,IH, I
EJJ
FK (goal)K \text{ (goal)}
GLL

Sub-questions:

  1. Apply Iterative Deepening Search (IDS). For each depth limit, starting at 00, list the nodes in the order they are visited, until KK is found.
  2. For branching factor b=10b = 10 and goal depth d=5d = 5, calculate the number of nodes IDS generates and the number BFS generates. Show that the overhead of repeated work is small.
  3. A chess program must make each move within 10 seconds. Explain why it uses iterative deepening instead of a fixed-depth search, and how the best move from one iteration helps alpha-beta pruning in the next.

Model Answer​

1. IDS Node Visit Trace​

  • Depth Limit 0: AA
  • Depth Limit 1: A,B,CA, B, C
  • Depth Limit 2: A,B,D,E,C,F,GA, B, D, E, C, F, G
  • Depth Limit 3: A,B,D,H,I,E,J,C,F,KA, B, D, H, I, E, J, C, F, K [Goal Found]

2. Node Generation Comparison (b=10,d=5b = 10, d = 5)​

  • Breadth-First Search (BFS): NBFS=1+b+b2+⋯+bd=∑i=0510i=111,111 nodesN_{\text{BFS}} = 1 + b + b^2 + \dots + b^d = \sum_{i=0}^{5} 10^i = \mathbf{111,111} \text{ nodes}
  • Iterative Deepening Search (IDS): NIDS=(d+1)⋅1+d⋅b+(d−1)⋅b2+⋯+1⋅bdN_{\text{IDS}} = (d+1) \cdot 1 + d \cdot b + (d-1) \cdot b^2 + \dots + 1 \cdot b^d NIDS=(6×1)+(5×10)+(4×100)+(3×1,000)+(2×10,000)+(1×100,000)N_{\text{IDS}} = (6 \times 1) + (5 \times 10) + (4 \times 100) + (3 \times 1,000) + (2 \times 10,000) + (1 \times 100,000) NIDS=6+50+400+3,000+20,000+100,000=123,456 nodesN_{\text{IDS}} = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = \mathbf{123,456} \text{ nodes}
  • Overhead Calculation: Overhead Ratio=NIDSNBFS=123,456111,111≈1.11(11% overhead)\text{Overhead Ratio} = \frac{N_{\text{IDS}}}{N_{\text{BFS}}} = \frac{123,456}{111,111} \approx \mathbf{1.11} \quad (11\% \text{ overhead})
  • Why overhead is small: In an exponential tree, the bottom level contains the vast majority of nodes (100,000100,000 out of 111,111≈90%111,111 \approx 90\%). Bottom-level nodes are generated only once, making upper-level recalculation negligible.

3. Chess Time Limit & Alpha-Beta Move Ordering​

  1. Anytime Property under Time Constraints:
    A fixed-depth search cannot predict whether depth dd will finish within 10 seconds; if interrupted, it returns no move. IDS is an anytime algorithm: if the timer runs out during iteration dd, the engine immediately outputs the best move completed at iteration d−1d-1.
  2. Move Ordering for Alpha-Beta Pruning:
    Alpha-Beta pruning reaches optimal O(bd/2)O(b^{d/2}) efficiency only if best moves are evaluated first. The best move identified at depth d−1d-1 (the principal variation) is tried first at depth dd, maximizing beta-cutoffs and pruning large swaths of the game tree.