# Informed Search (A*, IDA*), Adversarial Game Trees & CSP Arc Consistency (AC-3)
Exam: GATE Data Science & Artificial Intelligence (DA) (GATE DA)
Subject: Artificial Intelligence, Reasoning & RL
Canonical URL: https://gateandnet.com/exams/gate-da/artificial-intelligence/informed-search-heuristics-and-csp-arc-consistency

> Tree-search vs Graph-search A* optimality conditions, heuristic dominance & relaxed problems, IDA* linear memory bound, Minimax Alpha-Beta cutoffs, and CSP MRV/LCV & AC-3 complexity.

## 1. Subtle Exam Distinctions in $A^*$ Search ($f(n) = g(n) + h(n)$)

1. **Tree-Search $A^*$** is optimal whenever $h(n)$ is **Admissible** ($h(n) \le h^*(n)$, never overestimates true cost to goal).
2. **Graph-Search $A^*$** (with a `CLOSED` / explored set that never re-expands visited states) requires $h(n)$ to be **Consistent (Monotonic)**: $h(n) \le c(n, a, n') + h(n')$. An admissible *but inconsistent* heuristic can expand a state via a suboptimal path first and discard the optimal path later unless closed nodes can be reopened!
3. **Combining Admissible Heuristics:** If $h_1, h_2, \dots, h_m$ are all admissible, then:

$$
h_{\max}(n) = \max\big(h_1(n), h_2(n), \dots, h_m(n)\big)
$$

is **guaranteed admissible** AND **dominates** every $h_i$ (expands the fewest nodes)! Conversely, $h_1(n) + h_2(n)$ may overestimate $h^*(n)$ unless subproblems are strictly **disjoint pattern databases**.
4. **IDA* (Iterative Deepening $A^*$):** Performs DFS with increasing $f$-cost thresholds ($\text{next threshold} = \min f(n)$ among pruned nodes exceeding current bound), reducing memory from $\mathcal{O}(b^d)$ to $\mathcal{O}(b \cdot d)$!

## 2. Constraint Satisfaction Problems (CSPs): Ordering & AC-3

A CSP $(X, D, C)$ uses factored state representations to prune huge search spaces before branching:
- **Variable Ordering — MRV (Minimum Remaining Values / Fail-First):** Pick the unassigned variable with the **smallest current legal domain** $|D_i|$. Ties broken by **Degree Heuristic** (most constraints on remaining unassigned variables).
- **Value Ordering — LCV (Least Constraining Value / Succeed-First):** Try the value that **rules out the fewest choices** for neighboring variables!
- **Arc Consistency (AC-3):** Directed arc $X_i \to X_j$ is consistent iff $\forall x \in D_i, \; \exists y \in D_j$ satisfying $C_{ij}(x, y)$. Each of $2e$ directed arcs can be re-enqueued at most $d$ times, and checking an arc takes $\mathcal{O}(d^2) \implies \mathcal{O}(e d^3)$.

> [!TIP]
> **Tree-Structured CSP Shortcut:** If the constraint graph of a CSP has **no loops (is a tree)** with $n$ variables and max domain size $d$, it can be solved in **$\mathcal{O}(n \cdot d^2)$ polynomial time** (topological directional arc consistency + backtrack-free assignment)!

## Solved Practice Questions & PYQs

### [GATE DA / NET AI | MCQ]
Suppose $h_1(n)$ and $h_2(n)$ are both **admissible heuristics** for an $A^*$ search problem. Which composite heuristic below is **always guaranteed to be admissible** and expands no more nodes than either $h_1$ or $h_2$?
**Correct Answer:** B
**Solution:** Since $h_1(n) \le h^*(n)$ and $h_2(n) \le h^*(n)$, $\max(h_1(n), h_2(n)) \le h^*(n)$ is **always admissible** AND dominates both $h_1, h_2$ (and dominates $\min$ and the average!). $h_1 + h_2$ can overestimate $h^*(n)$.

### [GATE DA AI | MCQ]
In a two-player deterministic zero-sum game tree with branching factor $b = 9$ and depth $d = 6$, how many terminal leaf evaluations are required by **Alpha-Beta Pruning under optimal move ordering** ($\mathcal{O}(b^{d/2})$ scale)?
**Correct Answer:** B
**Solution:** For even depth $d$, exact minimum leaf nodes inspected by Alpha-Beta pruning under perfect move ordering is $2 b^{d/2} - 1 = 2(9^3) - 1 = 2(729) - 1 = \mathbf{1,457}$ (compared to $9^6 = 531,441$ for plain Minimax!).

### [GATE DA CSP | MCQ]
When solving a Constraint Satisfaction Problem (CSP), why is **MRV (Minimum Remaining Values)** used for choosing the next variable while **LCV (Least Constraining Value)** is used for ordering its values?
**Correct Answer:** A
**Solution:** Every unassigned variable *must* eventually be assigned (so **fail-first MRV** detects dead-ends immediately), whereas we only need **one** valid solution value (so **succeed-first LCV** maximizes survival of remaining domains)!
