A lot of AI comes down to one question: given where you are and where you want to be, which sequence of moves gets you there? This part teaches you to see a problem as a map of situations, explores that map blindly (breadth-first, depth-first, uniform-cost), then with a sense of direction (greedy and A*), and finally against an opponent who wants you to lose (minimax and alpha–beta pruning). Search has appeared in every GATE DA paper so far, often with a figure to trace by hand.
You need: what a graph is, and queues and stacks, from Python & DSA. Nothing else; every AI term is defined here.
Uninformed search: finding a route with no sense of direction
Uninformed (or “blind”) search explores a map of possible situations in a fixed order, using only the map itself and never a guess about how close the goal is.
GATE DA asks which algorithm is uninformed (2026 Q13), and every A* or game-tree question builds on the same ideas: frontier, expansion, path cost. The properties table in this chapter (complete? optimal? how much memory?) is a favourite source of one-mark questions.
It’s like looking for your friend’s seat in a stadium without a ticket number: you can sweep row by row, or run down one aisle to the end before trying the next, but you have no clue which direction is warmer.
Recognising uninformed algorithms, their properties, and tracing BFS or DFS orders; also the foundation for every A* question.
The problem: the team bus
The Bengaluru Backprops have an away match against the Kalinga Kernels in Bhubaneswar. Their team bus has a route planner: a program that looks at the road map and decides which roads to drive. That route planner is our first agent.
An agent is anything that observes its situation and chooses actions. A chess program, a delivery robot and the bus’s route planner are all agents. The agents in this chapter plan the whole sequence of actions in their head first, then carry it out.
A search problem has five parts. Each is shown with the bus example.
- States: every situation the world can be in, described just well enough to plan. Bus: which city it is in (8 cities, so 8 states).
- Initial state: where you start. Bengaluru.
- Actions: what you can do in a state. In Hyderabad: drive to Bengaluru, Vijayawada, Nagpur or Raipur.
- Goal test: a check that says whether a state is a goal. “Is the bus in Bhubaneswar?”
- Path cost: a number for each sequence of actions, the sum of the step costs. Total hours on the road.
The state space is the graph whose nodes are states and whose edges are actions, labelled with their step costs. A solution is a path from the initial state to a goal state; an optimal solution is one with the smallest path cost.
So “searching a state space” is a precise phrase: walk around this graph, starting at the initial state, until you find a path to a goal. For the bus the state space is just the road map. For other problems it is far larger and never drawn in full: in a puzzle, each arrangement of the pieces is one state.
Frontier and expansion: the one idea behind every algorithm
Every search algorithm in this part keeps two collections:
- the frontier: states you have discovered (you know a path to them) but have not yet explored from;
- the explored set (or closed set): states you have already explored from.
To expand a state means to take it out of the frontier, check whether it is a goal, and if not, put its neighbours (its children, or successors) into the frontier. Start with only the initial state in the frontier and repeat until you expand a goal or the frontier is empty.
That loop never changes. The only difference between BFS, DFS, uniform-cost search and A* is which state comes out of the frontier next.
1. frontier ← {initial state}; explored ← empty.
2. Repeat: if the frontier is empty, report failure. Remove one state $n$ from the frontier (the choice rule defines the algorithm).
3. If $n$ passes the goal test, return the path to $n$.
4. Add $n$ to explored. For each child of $n$ that is in neither the frontier nor explored, add it to the frontier and remember $n$ as its parent.
Without the explored set this is called tree search: it may revisit states and can loop forever on a map with cycles.
| Algorithm | Frontier is a… | Next state to expand |
|---|---|---|
| Breadth-first search (BFS) | queue (first in, first out) | the one discovered earliest: shallowest first |
| Depth-first search (DFS) | stack (last in, first out) | the one discovered most recently: deepest first |
| Uniform-cost search (UCS) | priority queue keyed by $g(n)$ | the one with the cheapest path cost so far |
Here $g(n)$ is the cost of the best path found so far from the start to $n$. Uniform-cost search is Dijkstra’s shortest-path algorithm, stopped as soon as the goal is expanded.
A convention matters in hand traces: we test for the goal when a state is expanded (taken out of the frontier), not when it is first discovered. For uniform-cost search this is essential: a cheaper route to the goal may still be waiting in the frontier. Ties are broken alphabetically unless a question says otherwise.
The bus starts in Bengaluru (BLR) and must reach Bhubaneswar (BBI); numbers on roads are hours. Pick an algorithm and press Step: the readout shows what comes out of the frontier and what is waiting. Compare the three routes. BFS finds the route with the fewest roads (3 roads, 29 h), DFS charges down one branch (30 h), and only uniform-cost search finds the cheapest route, 23 h through Chennai.
Trace uniform-cost search on the DPL map from Bengaluru (BLR) to Bhubaneswar (BBI). Roads (two-way, hours): BLR–HYD 9, BLR–MAA 5, MAA–VGA 7, HYD–VGA 4, HYD–NAG 8, HYD–RPR 12, NAG–RPR 5, RPR–BBI 8, VGA–VTZ 5, VTZ–BBI 6. In what order are the cities expanded, and what route is returned?
Expand BLR ($g = 0$). Frontier: MAA 5, HYD 9.
The frontier is a priority queue on $g$, the hours driven so far.
Expand MAA (5). Add VGA with $g = 5 + 7 = 12$. Frontier: HYD 9, VGA 12.
Chennai is cheaper to reach than Hyderabad, so it goes first even though it was added at the same time.
Expand HYD (9). Via HYD, VGA would cost 13, worse than 12, so VGA keeps 12. Add NAG 17 and RPR 21.
When a state already in the frontier is reached again, keep the cheaper of the two paths.
Expand VGA (12): add VTZ 17. Expand NAG (17, tied with VTZ, NAG first alphabetically): RPR via NAG would cost 22, no change.
Ties are broken alphabetically.
Expand VTZ (17): add BBI with $g = 23$. Then expand RPR (21): BBI via RPR would cost 29, no change.
BBI is now in the frontier, but we do not stop: RPR at 21 is cheaper and might have led to a cheaper route to BBI.
Expand BBI (23): the goal test passes. Order: BLR, MAA, HYD, VGA, NAG, VTZ, RPR, BBI. Route BLR–MAA–VGA–VTZ–BBI, 23 hours.
Uniform-cost search expands states in order of increasing $g$, so the first time it expands the goal, no cheaper route exists.
Depth-limited search and iterative deepening
DFS uses very little memory: it only holds the current path and the unexplored siblings along it. But on a huge or infinite state space it can dive forever down one branch. Two fixes:
- Depth-limited search (DLS): DFS that treats every state at depth $\ell$ (the depth limit) as if it had no children. It cannot go forever, but if the shallowest goal is deeper than $\ell$ it fails.
- Iterative deepening DFS (IDDFS): run DLS with $\ell = 0, 1, 2, \ldots$ until a goal is found. It finds the shallowest goal like BFS but needs only DFS’s memory.
Doesn’t IDDFS waste time redoing the top of the tree? Very little: almost all the nodes of a tree are in its bottom level, which IDDFS generates only once.
Each dot is a node of a search tree; the number in it is how many times iterative deepening generates it (the root is not counted in the totals). Raise the branching factor $b$ and watch the extra work over BFS shrink: with $b = 10$ and $d = 5$ it is about 11%, while the memory drops from 100,000 nodes to about 50.
Notation: $b$ = branching factor (maximum number of children of a state), $d$ = depth of the shallowest goal, $m$ = maximum depth of the state space, $C^*$ = cost of an optimal solution, $\epsilon$ = smallest step cost (positive), $\ell$ = depth limit. Complete means it always finds a solution when one exists; optimal means the solution it finds is a cheapest one.
| Complete? | Optimal? | Time | Memory | |
|---|---|---|---|---|
| BFS | yes (finite $b$) | only if all step costs are equal | $O(b^d)$ | $O(b^d)$ |
| Uniform-cost | yes (step costs $\ge \epsilon \gt 0$) | yes | $O(b^{1+\lfloor C^*/\epsilon\rfloor})$ | same as time |
| DFS | no (yes as graph search on a finite space) | no | $O(b^m)$ | $O(bm)$ |
| Depth-limited | no (fails if $\ell \lt d$) | no | $O(b^\ell)$ | $O(b\ell)$ |
| Iterative deepening | yes (finite $b$) | only if all step costs are equal | $O(b^d)$ | $O(bd)$ |
An algorithm is uninformed if it never uses an estimate of the distance to the goal: BFS, DFS, uniform-cost, depth-limited, iterative deepening, bidirectional. It is informed if it uses a heuristic $h(n)$: greedy best-first, A*, IDA*. Uniform-cost search uses costs, but costs already paid, so it is still uninformed.
Every state in a search tree has exactly 3 children, and the only goal is the last state generated at depth 3. Not counting the root, how many states does BFS generate before it finds the goal?
BFS generates every state at depths 1, 2 and 3: $b + b^2 + b^3$.
$3 + 9 + 27 = 39$. This is the $O(b^d)$ in the table: the last level dominates.
A search algorithm stores its frontier in a stack and always expands the most recently added state. Which algorithm is it?
- Breadth-first search
- Depth-first search
- Uniform-cost search
- A* search
Last in, first out means the newest, deepest state goes next.
(B). BFS uses a queue (first in, first out); uniform-cost and A* use priority queues keyed by $g$ and $g + h$.
Iterative deepening runs on a tree where every state has 2 children and the only goal is the last state at depth 3. Not counting the root, how many states are generated in total over all iterations ($\ell = 0, 1, 2, 3$)?
A state at depth $k$ is generated once in each iteration with $\ell \ge k$, so $d - k + 1$ times.
Depth 1: 2 states × 3 iterations = 6. Depth 2: 4 × 2 = 8. Depth 3: 8 × 1 = 8. Total $6 + 8 + 8 = 22$, against 14 for BFS.
Which of the following algorithms is NOT an example of uninformed search?
- Breadth First Search
- Depth First Search
- A* Search
- Depth-limited Search
Which one uses an estimate $h(n)$ of the remaining cost?
A* orders its frontier by $g(n) + h(n)$, where $h$ is a heuristic estimate of the cost still to go, so it is informed. The other three use only the structure of the graph. Answer (C). Official key: C.
Two-way roads, each taking 1 hour: S–A, S–B, A–C, C–D, D–G, B–G. Start S, goal G. Both searches are graph searches, test for the goal on expansion and consider neighbours in alphabetical order (DFS pushes them in reverse alphabetical order, so the alphabetically first is popped first). Which statement is correct?
- Both expand 5 states; BFS returns S–B–G and DFS returns S–A–C–D–G.
- Both return S–B–G, because it is the shortest route.
- BFS expands only S, A, B and then G; DFS returns S–A–C–D–G.
- DFS returns S–B–G and expands 3 states.
Write the queue (for BFS) and the stack (for DFS) after each expansion. For BFS, notice that C joins the queue before G does.
BFS. Queue [S]. Expand S → [A, B]. Expand A → add C: [B, C]. Expand B → add G: [C, G]. Expand C → add D: [G, D]. Expand G: goal. Expanded S, A, B, C, G (5 states); route S–B–G.
DFS. Stack top first: [S]. Expand S → [A, B]. Expand A → [C, B]. Expand C → [D, B]. Expand D → [G, B]. Expand G: goal. Expanded S, A, C, D, G (5 states); route S–A–C–D–G, twice as long.
Answer (A). (C) is what BFS does if it tests for the goal when a state is generated: it stops while expanding B. That variant is legitimate too, which is why exam questions state the convention. (B) and (D) assume DFS finds short routes; it does not.
Two-way roads with costs: S–A 1, S–B 5, S–D 4, A–B 2, A–C 6, B–C 2, B–G 9, C–G 3, D–G 6. Start S, goal G; goal test on expansion; ties alphabetical. Find (i) the cost of the route uniform-cost search returns, (ii) how many states it expands (count S and G), and (iii) the cost of the route BFS returns.
For uniform-cost search, keep updating a state’s $g$ when a cheaper path to it appears. B starts at 5 but drops when A is expanded.
Uniform-cost. Expand S (0): A 1, B 5, D 4. Expand A (1): B improves to 3, C 7. Expand B (3): C improves to 5, G 12. Expand D (4): G improves to 10. Expand C (5): G improves to 8. Expand G (8). Expanded S, A, B, D, C, G: 6 states; route S–A–B–C–G costing 8.
BFS. Expand S: queue [A, B, D]. Expand A: add C. Expand B: add G (its parent is B). Expand D, then C, then G. Route S–B–G costing $5 + 9 =$ 14. BFS minimises the number of roads, not the hours.
Tempting wrong answers: stopping uniform-cost search when G is first generated gives 12; counting only the states on the final route gives 5.
Which statements are true? ($b$ finite, all step costs positive.)
- Iterative deepening is complete and needs only $O(bd)$ memory.
- DFS as a graph search on a finite state space always finds a solution if one exists.
- BFS always returns an optimal solution when all step costs are positive.
- Depth-limited search with limit $\ell \ge d$ always returns a shallowest solution.
For (C), think of the bus map. For (D), DLS is still depth-first inside its limit.
(A) True: it finds the shallowest goal and only stores one path plus siblings.
(B) True: the explored set stops it revisiting states, and there are finitely many, so it eventually tries them all.
(C) False: BFS minimises the number of steps. On the bus map it returns a 29-hour route although a 23-hour route exists. It is optimal only when every step costs the same.
(D) False: inside the limit it still dives depth-first, so it can return a goal at depth $\ell$ before trying a shallower one in a later branch. Answer A; B.
- Write the frontier out after every expansion; most marks are lost by skipping one line.
- State the convention you use: goal test on expansion, ties alphabetical, graph or tree search.
- Ask “which state comes out next?”: that single rule identifies the algorithm.
- Calling BFS optimal without the “equal step costs” condition.
- Stopping uniform-cost search as soon as the goal enters the frontier.
- Calling uniform-cost search informed because it uses costs. Costs already paid are not a heuristic.
- A search problem is states, an initial state, actions, a goal test and path costs; the state space is the graph they form.
- Every algorithm repeats one loop: take a state from the frontier, test it, add its children. BFS uses a queue, DFS a stack, uniform-cost a priority queue on g(n).
- BFS and iterative deepening find the shallowest goal; only uniform-cost finds the cheapest when costs differ. IDDFS gets BFS’s answer with DFS’s O(bd) memory.
The team bus wants the route with the fewest roads, whatever the hours. Which strategy explores every city one road away before any city two roads away?
Uniform-cost search keeps its frontier as
Why is iterative deepening preferred to BFS for very large trees with unit step costs?
Informed search: heuristics, greedy best-first and A*
Informed search uses a heuristic, a cheap estimate of the cost still to go, to expand the most promising states first; A* combines it with the cost already paid and still guarantees the cheapest route.
A* is the most examined search topic in GATE DA: tracing its expansion order (2025 Q44, sample Q27) and knowing which heuristics are admissible (2024 Q23, sample Q46). Expect at least one question, often two marks.
It’s like driving with a sign that says “Bhubaneswar 600 km” at each junction: you still count the kilometres you have driven, but the signs stop you wandering south.
Trace A* on a figure, find the largest admissible value of h, or decide which combination of heuristics stays admissible.
Uniform-cost search found the bus’s best route, but it expanded every city cheaper than 23 hours, including Nagpur and Raipur, which are in the wrong direction for a good route. It had no idea where Bhubaneswar was.
Suppose the planner also knows, for each city, a rough estimate of the hours still needed, say from the straight-line distance. Bengaluru is about 15 hours away, Visakhapatnam about 5. That estimate is a heuristic.
A heuristic function $h(n)$ estimates the cost of the cheapest path from state $n$ to a goal. It must be cheap to compute and $h(\text{goal}) = 0$. Write $h^*(n)$ for the true cheapest cost from $n$ to a goal. Example: on the bus map $h(\text{VTZ}) = 5$ while $h^*(\text{VTZ}) = 6$.
Both use the generic graph search with a priority queue; only the priority differs.
Greedy best-first search: expand the state with the smallest $h(n)$. It heads straight for whatever looks closest.
A* search: expand the state with the smallest $$f(n) = g(n) + h(n),$$ where $g(n)$ is the cost already paid to reach $n$. So $f(n)$ estimates the cost of the cheapest complete route through $n$. With $h = 0$ everywhere, A* is uniform-cost search.
$h$ is admissible if it never overestimates: $h(n) \le h^*(n)$ for every state $n$. Straight-line distance is admissible for road travel: no road is shorter than the straight line.
$h$ is consistent (or monotone) if for every edge $n \to n'$ with cost $c(n, n')$: $$h(n) \le c(n, n') + h(n').$$ This is a triangle inequality: your estimate cannot drop by more than the step you just paid for. Every consistent heuristic (with $h(\text{goal}) = 0$) is admissible; the converse is false.
A* tree search returns an optimal solution if $h$ is admissible. A* graph search (with an explored set, never reopening closed states) returns an optimal solution if $h$ is consistent. With a consistent $h$, the $f$-values of expanded states never decrease.
Why admissibility is enough for tree search, in two lines. Let $C^*$ be the optimal cost. Some state $n$ on the optimal route is always waiting in the frontier with $f(n) = g(n) + h(n) \le g(n) + h^*(n) = C^*$. A worse goal $G_2$ has $f(G_2) = g(G_2) \gt C^*$, so $n$ always comes out first, and A* cannot return $G_2$ before finishing the optimal route.
For graph search, admissibility is not enough: A* may close a state via an expensive path and then never reopen it. The Try it below shows exactly this.
Run A* with the default heuristic: it expands only 6 cities (uniform-cost search needed 8) and finds the 23-hour route. Then run Greedy: it trusts $h$ alone and returns the 29-hour route through Raipur. Finally, drag h(Chennai) to 18. That is still admissible (the true cost from Chennai is 18) but no longer consistent, and A* graph search now returns 24 hours: it closes Vijayawada via Hyderabad before it explores Chennai.
The state graph shows the action cost along the edges and the heuristic function h associated with each state.
Suppose $A^*$ algorithm is applied on this state graph using priority queue to store the frontier. In what sequence are the nodes expanded?
- S,A,E,C,B,D,G
- S,E,A,C,B,D,G
- S,A,E,B,C,D,G
- S,A,B,E,C,D,G
Expand S. Children: A with $g = 4$, $f = 4 + 2 = 6$; E with $g = 1$, $f = 1 + 6 = 7$.
A* orders by $f = g + h$, not by $g$ (which would pick E) or $h$ alone.
Expand A ($f = 6$). Add B: $g = 6$, $f = 6 + 2 = 8$. Frontier: E 7, B 8.
This rules out (B) and (D): after S comes A, and after A comes E (7 is less than 8).
Expand E ($f = 7$). Add C: $g = 1 + 2 = 3$, $f = 3 + 6 = 9$. Frontier: B 8, C 9.
C is reached cheaply through E, but its large heuristic value pushes $f$ to 9.
Expand B ($f = 8$). Via B, C would have $g = 8$, worse than 3, so nothing changes. Expand C ($f = 9$). Add D: $g = 6$, $f = 8$.
This settles it: B (8) before C (9). Option (A) puts C before B.
Expand D ($f = 8$). Add G: $g = 9$, $f = 9$. Expand G: goal. Sequence S, A, E, B, C, D, G, answer (C), route S–E–C–D–G of cost 9.
D’s $f$ (8) is lower than C’s (9) although D comes later: $h(\text{C}) = 6 \gt c(\text{C}, \text{D}) + h(\text{D}) = 5$, so this $h$ is not consistent. It is still admissible, and the answer is optimal here. Official key: C.
If $h_1$ and $h_2$ are admissible, then $\max(h_1, h_2)$, $\min(h_1, h_2)$, any weighted average $\lambda h_1 + (1 - \lambda)h_2$ and $|h_1 - h_2|$ are all admissible: each is at most $\max(h_1, h_2) \le h^*$. The sum $h_1 + h_2$ and the product $h_1 h_2$ can overestimate. Of two admissible heuristics, the larger one (it dominates) is better: A* expands no more states with it.
A standard way to build admissible heuristics: solve a relaxed problem, one with fewer restrictions. Its optimal cost can only be lower than the real one.
On the DPL map (BLR–MAA 5, BLR–HYD 9; $h(\text{MAA}) = 13$, $h(\text{HYD}) = 11$), A* expands Bengaluru first. What are the $f$-values of Chennai and Hyderabad in the frontier after that?
$f = g + h$, with $g$ the hours from Bengaluru.
$f(\text{MAA}) = 5 + 13 = 18$ and $f(\text{HYD}) = 9 + 11 = 20$. So A* expands Chennai next, while greedy best-first (which compares only 13 and 11) would choose Hyderabad.
Let $h_1$ and $h_2$ be two admissible heuristics used in $A^*$ search. Which ONE of the following expressions is always an admissible heuristic?
- $h_1 + h_2$
- $h_1 \times h_2$
- $h_1/h_2,\ (h_2 \neq 0)$
- $|h_1 - h_2|$
Heuristics are non-negative. Compare each option with $\max(h_1, h_2)$.
Since $h_1, h_2 \ge 0$, $|h_1 - h_2| \le \max(h_1, h_2) \le h^*$, so (D) never overestimates.
The others can: if $h_1 = h_2 = h^* = 3$, then $h_1 + h_2 = 6$ and $h_1 h_2 = 9$; if $h_1 = 4$, $h_2 = 0.5$ and $h^* = 4$, then $h_1/h_2 = 8$. Answer (D). Official key: D.
Consider the search space depicted in the figure below.
S is the initial state. G1 and G2 are two states that satisfy the goal test. The cost of traversing from one state to another is depicted by the numerical value close to the edge connecting the two states. The estimated cost to the goal is reported inside the states. Use alphabetical order of nodes to break ties. Which goal state is reached if you perform A* (graph) search? What is the largest value that the heuristic function can take for node A while still being admissible?
- G1 and 16
- G1 and 15
- G2 and 16
- G2 and 15
Run A* and keep the frontier with $f$-values; several states tie at the end, so the alphabetical rule matters. For the second part, A’s only exit is to B: what is the cheapest cost from B to a goal?
A* (graph search). Expand S (8): A $f = 3 + 10 = 13$, B $8 + 4 = 12$, F $6 + 5 = 11$. Expand F (11): D $10 + 3 = 13$, H $10 + 6 = 16$. Expand B (12): G1 $18 + 0 = 18$ (D via B costs 12, worse). Expand A (13, ties with D, A first): B via A costs 8, no better. Expand D (13): C $16 + 2 = 18$, E $13 + 4 = 17$. Expand H (16): G2 $18$. Expand E (17): G2 via E also 18, F via E costs 15, worse. Now C, G1 and G2 all have $f = 18$; alphabetically C, then G1. Expand C: G1 via C costs 20, no better. Expand G1: goal, cost 18 (route S–B–G1).
Largest admissible $h(\text{A})$. From A the only edge is A→B (5). From B the cheapest route to a goal is B→G1 (10); B→D→E→G2 costs 12. So $h^*(\text{A}) = 5 + 10 = 15$, and admissibility allows $h(\text{A}) \le 15$. Answer (B). (Sample paper, no official key; this is our answer.)
Consider the grid world shown in the figure below.
An agent is planning to move from the starting location $(x_s, y_s)$ to the final location $(x_f, y_f)$. The obstacles along the path are triangular in form. Consider the following heuristic functions to conduct A* search.
− $h_c$ assumes the obstacles are the smallest circles circumscribing the triangles.
− $h_r$ assumes the obstacles are smallest rectangles circumscribing the triangles.
− $h_c'$ assumes the obstacles are largest circles inscribed in the triangles.
− $h_r'$ assumes the obstacles are largest rectangles inscribed the triangles.
Which of the following statement(s) is(are) true?
- $h_c$ is an admissible heuristic
- $h_r$ is an admissible heuristic
- $h_c'$ is an admissible heuristic
- $h_r'$ is an admissible heuristic
Each heuristic is the shortest path length in an imagined world. Is that world easier (fewer blocked points) or harder than the real one?
A shape inscribed in a triangle lies inside it, so with inscribed obstacles less of the grid is blocked. Every path that avoids the real triangles also avoids the smaller shapes, so the shortest path in the imagined world is never longer than the real one: $h_c'$ and $h_r'$ never overestimate. They are relaxed problems, hence admissible.
A circumscribed shape contains the triangle, so more is blocked and the imagined shortest path can be longer than the real one; $h_c$ and $h_r$ can overestimate. Answer C; D. (Sample paper, no official key; this is our answer.)
One-way roads: S→A cost 2, A→G cost 4, S→B cost 3, B→G cost 4. Heuristic: $h(\text{S}) = 5$, $h(\text{A}) = 4$, $h(\text{B}) = 1$, $h(\text{G}) = 0$. Which statements are true?
- $h$ is admissible.
- $h$ is consistent.
- A* graph search returns a route of cost 6.
- Greedy best-first search returns a route of cost 7.
First compute $h^*$ for every state. For consistency, test $h(n) \le c(n, n') + h(n')$ on all four edges.
$h^*(\text{A}) = 4$, $h^*(\text{B}) = 4$, $h^*(\text{S}) = \min(2 + 4, 3 + 4) = 6$. Every $h \le h^*$: (A) true.
Edge S→B: $h(\text{S}) = 5 \gt 3 + h(\text{B}) = 4$. (B) false.
A*: expand S; A $f = 2 + 4 = 6$, B $f = 3 + 1 = 4$. Expand B: G $g = 7$, $f = 7$. Expand A (6): G improves to $g = 6$. Expand G: cost 6. (C) true: the inconsistency did no harm here, because no closed state needed reopening.
Greedy: S, then B ($h = 1$ beats 4), then G: route S–B–G of cost 7. (D) true. Answer A; C; D. If you ticked (B), you probably checked only edges into the goal.
One-way roads: S→A 3, S→B 6, A→B 2, A→G 7, B→G 3. Known values: $h(\text{S}) = 6$, $h(\text{B}) = 2$, $h(\text{G}) = 0$. Find (i) the largest integer value of $h(\text{A})$ that keeps $h$ admissible, and (ii) the largest that keeps $h$ consistent.
Admissible: compare with $h^*(\text{A})$. Consistent: every edge out of A gives an upper bound on $h(\text{A})$, and the edge into A gives a lower bound.
(i) $h^*(\text{A}) = \min(7, 2 + 3) = 5$. The other states are fine ($h(\text{B}) = 2 \le 3$, $h(\text{S}) = 6 \le 8$), so the largest admissible value is 5.
(ii) Edges out of A: $h(\text{A}) \le 2 + h(\text{B}) = 4$ and $h(\text{A}) \le 7 + 0 = 7$. Edge into A: $h(\text{S}) = 6 \le 3 + h(\text{A})$ needs $h(\text{A}) \ge 3$. The other edges hold. So $3 \le h(\text{A}) \le 4$: the largest consistent value is 4.
The gap between 5 and 4 is the point: consistency is a stronger demand. Answering 7 uses only the direct edge A→G and forgets the cheaper route through B.
One-way roads: S→A 2, S→B 1, A→G 2, B→G 5. Heuristic: $h(\text{S}) = 0$, $h(\text{A}) = 5$, $h(\text{B}) = 1$, $h(\text{G}) = 0$. A* (goal test on expansion) returns a route of cost
- 4, because A* is always optimal when $h(\text{G}) = 0$
- 6, because $h(\text{A})$ overestimates the true cost from A
- 6, because A* stops as soon as the goal is generated
- 7
Compute $f$ for A and B after expanding S, then follow the smaller one.
Expand S: A $f = 2 + 5 = 7$, B $f = 1 + 1 = 2$. Expand B: G $g = 6$, $f = 6$. Now G (6) beats A (7), so A* expands G and returns cost 6, although S–A–G costs 4.
The reason is $h(\text{A}) = 5 \gt h^*(\text{A}) = 2$: the heuristic is not admissible, so it hid the good route. Answer (B). (C) gives the right number for the wrong reason: the goal test here is on expansion. (A) is false: $h(\text{G}) = 0$ is required but not sufficient. (D) adds the heuristic into the route cost.
- Write each frontier entry as “state: g + h = f”; it makes ties and updates visible.
- To test admissibility, compute $h^*$ for every state by working backwards from the goal.
- To test consistency, check $h(n) \le c(n, n') + h(n')$ on every edge, in the edge’s direction.
- Ordering A* by $g$ or by $h$ alone (those are uniform-cost and greedy).
- Believing an admissible heuristic guarantees optimal A* graph search; that needs consistency.
- Adding two admissible heuristics and expecting the sum to stay admissible.
- A* expands the state with the smallest f(n) = g(n) + h(n); greedy best-first uses h(n) alone and is not optimal.
- Admissible: h(n) ≤ h*(n). Consistent: h(n) ≤ c(n, n′) + h(n′) on every edge. Consistent implies admissible.
- Admissible is enough for optimal A* tree search; graph search needs consistency. max, min and |h₁ − h₂| of admissible heuristics stay admissible; the sum does not.
If the heuristic is $h(n) = 0$ for every state, A* behaves exactly like
Which statement is always true?
$h_1$ and $h_2$ are admissible and $h_2(n) \ge h_1(n)$ for every $n$. Which should A* use?
Adversarial search: minimax and alpha–beta pruning
Adversarial search plans moves when an opponent moves too: minimax assumes the opponent always picks the reply that is worst for you, and alpha–beta pruning gets the same answer while skipping branches that cannot matter.
A game-tree question has appeared in every GATE DA paper: the meaning of α and β (2024 Q25), the value at the root (2026 Q30), and which branches are pruned (2025 Q43, sample Q31).
It’s like planning a chess move by asking “what’s their best reply?” for each option, and abandoning an option the moment you find one reply that makes it worse than something you already have.
Compute a minimax value, say which subtrees alpha–beta prunes, or find the range of a leaf for which pruning happens.
The problem: two captains
Before the final, the Kalinga Kernels’ captain picks one of three batting plans. The Hyderabad Hyperplanes’ captain sees the plan and picks one of three bowling plans in reply. A model predicts the Kernels’ winning margin (in runs) for each of the nine combinations. The Kernels want the margin high; the Hyperplanes want it low.
A route planner chooses every step itself. Here half the choices belong to someone working against you. That changes the question from “which path is best?” to "which move is best, assuming the reply is as bad for me as possible?"
A two-player, turn-taking, zero-sum game (one player’s gain is the other’s loss) with perfect information is drawn as a game tree:
- The root is the current position; levels alternate between the player MAX (wants a high score) and the opponent MIN (wants it low). One level of moves is a ply.
- Leaves (terminal states) carry a utility: the final score from MAX’s point of view. Kernels’ winning margin: MAX = Kernels, MIN = Hyperplanes.
The minimax value of a node is: its utility, if it is a leaf; the largest value among its children, if MAX moves there; the smallest, if MIN moves there. Compute it bottom-up (by a depth-first walk). At the root, MAX plays the move leading to the child with the largest value.
Minimax visits every node: time $O(b^m)$ for branching factor $b$ and depth $m$, memory $O(bm)$.
Alpha–beta pruning: skip what cannot matter
In the “DPL match” tree of the Try it below, the Kernels’ first plan B leads to margins 3, 12, 8; the Hyperplanes would choose 3, so plan B is worth 3. Now the Kernels look at plan C. The first reply gives margin 2. Stop right there: whatever the other two replies give, the Hyperplanes can hold plan C to at most 2, and the Kernels already have 3. The remaining leaves under C can be skipped without being looked at.
Alpha–beta pruning formalises this with two numbers carried down the tree.
At any point of the depth-first walk:
- $\alpha$ = the highest value MAX is already guaranteed at some choice point on the path from the root (MAX’s best option so far). It starts at $-\infty$ and only rises at MAX nodes.
- $\beta$ = the lowest value MIN is already guaranteed on the path (MIN’s best option so far). It starts at $+\infty$ and only falls at MIN nodes.
Values between $\alpha$ and $\beta$ are the only ones that can still change the decision. As soon as $\alpha \ge \beta$ at a node, its remaining children are pruned: one of the players above will never let play reach this node.
Walk the tree left to right, depth first, passing $(\alpha, \beta)$ down.
At a MAX node: after each child returns value $v$, set $\alpha \leftarrow \max(\alpha, v)$. If $\alpha \ge \beta$, prune its remaining children.
At a MIN node: after each child returns value $v$, set $\beta \leftarrow \min(\beta, v)$. If $\alpha \ge \beta$, prune its remaining children.
A node passes its value up to its parent; the parent’s $\alpha$ and $\beta$ were never changed by the child.
Press Step to walk the tree; the current node is outlined and its α and β are shown above it. In “DPL match”, two leaves are pruned. Switch to “Best order”: the best moves come first and four of nine leaves are skipped. “Worst order” prunes nothing. Then press “Shuffle leaves” a few times and compare with “Plain minimax”: the root value never changes, only the number of leaves looked at.
(1) Alpha–beta returns exactly the minimax value at the root; only the values of pruned subtrees are left unknown. (2) How much it prunes depends on the order children are examined. With perfect ordering it looks at about $O(b^{m/2})$ leaves instead of $O(b^m)$, so it can search twice as deep in the same time; with random ordering about $O(b^{3m/4})$; with the worst ordering it prunes nothing.
Consider the game tree shown below.
The value below each node is the output of the utility function. The subtrees rooted at which of these nodes will be pruned because of alpha-beta pruning?
- m and j
- r and j
- h and p
- no nodes are pruned
Subtree b (MIN), with $\alpha = -\infty$, $\beta = +\infty$. Its child e (MAX) sees k = 3 and l = 0, so e = 3. Back at b: $\beta = 3$. Then f = 2, so b = min(3, 2) = 2.
Nothing can be pruned yet: no bound is finite until a first value comes back to a choice point.
Back at a (MAX): $\alpha = 2$. MAX is now guaranteed at least 2.
$\alpha$ is the best value MAX has found so far along the path.
Subtree c (MIN), $(\alpha, \beta) = (2, +\infty)$. g = 6, so $\beta = 6$. Go into h (MAX) with $(2, 6)$, then into m (MIN) with $(2, 6)$. q = 1: m’s $\beta$ becomes 1, and now $\alpha = 2 \ge \beta = 1$. Prune r.
m will be worth at most 1, but MAX at the root already has 2, so play never reaches m on purpose; r’s value does not matter.
m returns 1, so h’s $\alpha = \max(2, 1) = 2$. Then n = 6: h = 6, and $\alpha = 6 \ge \beta = 6$, but h has no children left. h returns 6; c = min(6, 6) = 6. At a: $\alpha = 6$.
h itself is not pruned: both its children were needed to know its value.
Subtree d (MIN), $(6, +\infty)$. i = 1: $\beta = 1 \le \alpha = 6$. Prune j (and with it o and p). Root value 6, MAX plays to c. Answer (B) r and j.
d is worth at most 1 to MAX, who already has 6. (Sample paper, no official key; this is our answer.) Load “Sample Q31” in the Try it to watch every step.
To find when a leaf is pruned, write the condition $\alpha \ge \beta$ at the node just before that leaf, with $\alpha$ and $\beta$ as expressions in the unknown. A MIN node’s remaining children are pruned once its running minimum is $\le \alpha$; a MAX node’s once its running maximum is $\ge \beta$. Ties prune ($\ge$, not $\gt$).
The Kernels (MAX) choose plan 1, 2 or 3; then the Hyperplanes (MIN) choose a reply and the game ends. Margins for plan 1: 4, 7, 9; plan 2: 2, 8, 6; plan 3: 5, 5, 10. What is the minimax value of the root?
Each MIN node takes the smallest of its three leaves; the root takes the largest of those.
MIN values: plan 1 → 4, plan 2 → 2, plan 3 → 5. MAX takes the largest: 5, by playing plan 3. Plan 2 has the largest leaf (8), but the Hyperplanes would never allow it.
Consider the following statement:
In adversarial search, $\alpha$–$\beta$ pruning can be applied to game trees of any depth where $\alpha$ is the (m) value choice we have formed so far at any choice point along the path for the MAX player and $\beta$ is the (n) value choice we have formed so far at any choice point along the path for the MIN player.
Which ONE of the following choices of (m) and (n) makes the above statement valid?
- (m) = highest, (n) = highest
- (m) = lowest, (n) = highest
- (m) = highest, (n) = lowest
- (m) = lowest, (n) = lowest
What does each player want: high values or low values?
MAX’s best choice so far is the highest value it can guarantee; MIN’s best is the lowest. So (m) = highest and (n) = lowest. Answer (C). Official key: C.
Consider the game tree for a two-player turn-taking minimax game as shown in the figure. The value of a terminal node represents the utility of the game state if the game ends there. The numbers written next to the edges denote the strategies.
There are two players MAX and MIN. At any particular state of the game, MAX prefers to move to a state of maximum value. On the other hand, MIN prefers to move to a state of minimum value.
Suppose MAX starts the game at the root and has three strategies: 1, 2 and 3. Next, MIN plays and also has three strategies: 1, 2 and 3. The game ends there. Both players always take optimal strategies throughout the game.
At the root, the best strategy for MAX is ___________ . (Answer in integer)
Find what MIN would do after each of MAX’s strategies. The answer is a strategy number, not a value.
MIN values: strategy 1 → min(8, 6, −1) = −1; strategy 2 → min(1, 5, 7) = 1; strategy 3 → min(−4, −3, −12) = −12. MAX picks the largest, 1, which is strategy 2. Official key: 2.
Strategy 1 holds the largest leaf (8) but MIN would answer with −1. Note the question asks for the strategy (2), not the root value (1).
Consider game trees Tree-1 and Tree-2 as shown. The first level is a MAX agent and the second level is a MIN agent. The value in the square node is the output of the utility function.
For what ranges of $x$ and $y$, the right child of node $B$ and the right child of node $E$ will be pruned by alpha-beta pruning algorithm?
- $x \in [1, \infty)$ and $y \in (-\infty, 2]$
- $x \in (-\infty, 2]$ and $y \in (-\infty, 5]$
- $x \in (-\infty, 2]$ and $y \in [2, \infty)$
- $x \in [1, \infty)$ and $y \in (-\infty, 5]$
Find $\alpha$ at the root after its left child, then write "running minimum $\le \alpha$" at B and at E.
Tree-1. A’s left child is 2, so $\alpha = 2$. At B (MIN), after the leaf $x$, $\beta = x$. The right child is pruned when $\alpha \ge \beta$: $x \le 2$, i.e. $x \in (-\infty, 2]$.
Tree-2. D = min(5, y), so at C, $\alpha = \min(5, y)$. At E, after the leaf 2, $\beta = 2$. Pruned when $\min(5, y) \ge 2$, i.e. $y \ge 2$: $y \in [2, \infty)$.
Answer (C). Official key: C. The trap in (A) and (D) is to compare $x$ with the pruned leaf’s value 1; pruning never depends on the leaf being pruned.
A three-ply game tree: the root R is MAX with MIN children B and C. B has MAX children D (leaves 3, 5) and E (leaves 6, 9). C has MAX children F (leaves 1, 2) and G (leaves 0, −1). Alpha–beta runs left to right. How many of the 8 leaves are evaluated?
Track $(\alpha, \beta)$ into every node. Once B has a value, R’s $\alpha$ is set; what does that mean for C after F returns?
D = max(3, 5) = 5, so B’s $\beta = 5$. Enter E with $(-\infty, 5)$: leaf 6 makes E’s $\alpha = 6 \ge 5$, so 9 is pruned. B = min(5, 6) = 5; at R, $\alpha = 5$.
Enter C with $(5, +\infty)$, then F with $(5, +\infty)$: leaves 1 and 2 give F = 2 (no pruning inside F, as $\alpha$ stays 5 and $\beta$ is infinite). Back at C, $\beta = 2 \le \alpha = 5$, so G is pruned (leaves 0 and −1).
Evaluated: 3, 5, 6, 1, 2, so 5 leaves; root value 5. A common slip is to prune leaf 2 inside F: F is a MAX node, and its running maximum 1 is not $\ge \beta = +\infty$.
A MAX root has two MIN children. The left one has leaves 5 and 8. The right one has leaves $x$, 4 and 7, in that order. Alpha–beta runs left to right. Which statement is correct?
- The leaf 7 is pruned for every value of $x$.
- The leaf 7 is pruned only when $x \le 5$.
- The leaf 4 is pruned for every value of $x$.
- When $x \gt 5$, nothing is pruned.
The root’s $\alpha$ is 5 after its left child. Consider $x \le 5$ and $x \gt 5$ separately.
Left child: min(5, 8) = 5, so $\alpha = 5$ at the root. At the right MIN node, after $x$, $\beta = x$.
If $x \le 5$: $\alpha \ge \beta$ immediately, so 4 and 7 are both pruned. If $x \gt 5$: no pruning yet; the leaf 4 gives $\beta = 4 \le 5$, so 7 is pruned.
Either way 7 is pruned: (A). (B) forgets that the second leaf can trigger pruning too; (C) fails for $x \gt 5$; (D) is wrong because 4 arrives before 7.
Which statements about alpha–beta pruning are true?
- It always returns the same value at the root as minimax.
- With perfect move ordering it examines about $O(b^{m/2})$ leaves for branching factor $b$ and depth $m$.
- The number of nodes it prunes does not depend on the order in which children are examined.
- At a MIN node, the remaining children are pruned as soon as the node’s running minimum is less than or equal to $\alpha$.
Use the Try it: compare “Best order” and “Worst order” on the same nine leaves.
(A) True: it only skips subtrees that cannot affect the root’s decision. (B) True: perfect ordering halves the effective depth. (C) False: the same nine leaves are pruned 4 times with the best order and never with the worst. (D) True: that is the condition $\alpha \ge \beta$ with $\beta$ the running minimum. Answer A; B; D.
- Write $(\alpha, \beta)$ next to each node as you enter it, and update it after every child.
- Remember who updates what: MAX nodes raise $\alpha$, MIN nodes lower $\beta$.
- When asked “which subtree is pruned”, name the child whose value was never needed, not its parent.
- Pruning on the value of the leaf you are about to skip; you never look at it.
- Using $\gt$ instead of $\ge$: ties prune.
- Reporting the root’s value when the question asks for the move (strategy) that achieves it.
- Minimax: leaves give utilities, MAX nodes take the maximum of their children, MIN nodes the minimum; MAX plays the move to the best child.
- α is MAX’s best guaranteed value on the path (highest), β is MIN’s (lowest); prune the remaining children as soon as α ≥ β.
- Pruning never changes the root value; good move ordering cuts the work from O(b^m) to about O(b^(m/2)).
MAX can choose move 1, after which MIN can reach outcomes 10 or −20, or move 2, after which MIN can reach 3 or 4. Assuming MIN plays well, MAX should choose
Alpha–beta prunes the remaining children of a node when
Compared with minimax, alpha–beta pruning
All roads take different times. Which uninformed search is guaranteed to find the fastest route?
A* expands the frontier state with the smallest
A heuristic has h(A) = 6, h(B) = 2 and an edge A → B of cost 3. Which is true?
At a MIN node, α = 4 and the first child returns 3. What happens?
Minimax computes values with a depth-first walk. Its memory use for branching factor b and depth m is