Skip to content
GATEiit

GATE DA · Artificial Intelligence

Search: informed, uninformed and adversarial

Problem solving as search: uninformed strategies (BFS, DFS, UCS, IDS), informed search with heuristics (greedy, A*), and game search (minimax, alpha-beta). GATE asks expansion orders, path costs, complexities and pruning counts.

Before you start

Concept notes

1. Search problems and how strategies are judged

A search problem has an initial state, a set of actions, a transition model (the state an action leads to), a goal test and a path cost (sum of step costs). A solution is a path from the initial state to a goal; an optimal solution has the least path cost.

Search keeps a frontier (generated but not yet expanded nodes). Expanding a node means generating its children. Tree search may revisit states; graph search keeps an explored set and never expands a state twice.

Strategies are compared on four criteria:

  • Complete: finds a solution whenever one exists.
  • Optimal: finds a least-cost solution.
  • Time: number of nodes generated.
  • Space: maximum number of nodes kept in memory.

The measures use b = branching factor, d = depth of the shallowest goal, m = maximum depth of the tree, C∗ = optimal cost and ϵ = smallest step cost. Read every question for whether the goal test is applied when a node is generated or when it is expanded: BFS usually tests on generation, UCS and A* must test on expansion to stay optimal.

2. Uninformed (blind) search

Uninformed strategies use only the problem definition, no estimate of distance to the goal. They differ only in which frontier node is expanded next.

Strategy Frontier Complete? Optimal? Time Space
BFS FIFO queue Yes (b finite) Yes if all step costs equal O(bd) O(bd)
UCS priority on g(n) Yes if costs ≥ϵ>0 Yes O(b1+⌊C∗/ϵ⌋) same
DFS LIFO stack No (infinite depth, loops) No O(bm) O(bm)
Depth-limited (ℓ) stack, cut at ℓ No if ℓ<d No O(bℓ) O(bℓ)
Iterative deepening (IDS) DLS for ℓ=0,1,2,… Yes Yes if step costs equal O(bd) O(bd)
Bidirectional BFS two queues Yes Yes (equal costs) O(bd/2) O(bd/2)

Uniform-cost search (UCS) always expands the node of least path cost g(n); it is Dijkstra's algorithm with a goal test. IDS repeats the shallow levels, but the last level dominates: a node at depth i is generated d+1−i times, so the total is still O(bd). IDS combines the memory of DFS with the completeness and optimality of BFS, which makes it the preferred blind method when the depth of the goal is unknown.

3. Informed search: greedy best-first and A*

A heuristic h(n) estimates the cost of the cheapest path from n to a goal, with h(goal)=0.

  • Greedy best-first expands the node with the smallest h(n). It is fast but neither complete (in tree search) nor optimal.
  • A* expands the node with the smallest f(n)=g(n)+h(n), the estimated cost of the best solution through n.

A heuristic is admissible if it never overestimates: h(n)≤h∗(n) for every n, where h∗ is the true cost to the goal. It is consistent (monotone) if h(n)≤c(n,n′)+h(n′) for every edge n→n′. Consistent implies admissible (given h(goal)=0); the converse is false.

Version Condition for A* to be optimal
Tree search h admissible
Graph search (explored set) h consistent

With a consistent h, the f values along any path never decrease, so the first time A* expands a goal it has the optimal cost. With h=0, A* becomes UCS. If h2(n)≥h1(n) for all n and both are admissible, h2 dominates and A* with h2 expands no more nodes. For the 8-puzzle, the number of misplaced tiles and the sum of Manhattan distances are both admissible, and Manhattan dominates. The maximum of admissible heuristics is admissible.

SABCG h 5h 4h 3h 2h 0 1425136
Search graph with step costs on edges and heuristic values h beside each node

4. Adversarial search: minimax and alpha-beta pruning

In a two-player, zero-sum game with perfect information, MAX moves to maximise and MIN to minimise the final utility. The minimax value of a node is its utility if terminal, the maximum of its children's values at a MAX node, and the minimum at a MIN node. Minimax is a depth-first walk of the whole game tree: time O(bm), space O(bm).

Alpha-beta pruning returns the same root value while skipping branches that cannot affect it. It carries two bounds down the tree:

  • α = best value MAX can already guarantee on the path (starts at −∞),
  • β = best value MIN can already guarantee on the path (starts at +∞).

At a MAX node, update α=max⁡(α,v); at a MIN node, β=min⁡(β,v). As soon as α≥β, the remaining children of that node are pruned.

In the tree below, MIN node B returns 5, so α=5 at the root. At C the first leaf is 3, so C is worth at most 3, below 5: its other leaves are pruned. At D the second leaf 2 does the same.

Pruning depends on move ordering. With perfect ordering alpha-beta examines about O(bm/2) nodes (it can search twice as deep in the same time); with the worst ordering it prunes nothing, O(bm). Pruning never changes the root value; it may change values computed at interior nodes, which become only bounds.

5MAX 532MIN 586 397 7210 at C: 3 is at most alpha 5, so prune; at D: 2 is at most 5, so prune
Alpha-beta on a two-ply tree (left to right): dashed leaves 9, 7 and 10 are never evaluated; the root value is 5

Formulas to remember

Nodes generated by BFSGoal test on generation, goal at depth d
b+b2+⋯+bd=O(bd)
Nodes generated by IDSA node at depth i is generated d+1−i times
d b+(d−1) b2+⋯+1⋅bd=O(bd)
UCS time and spaceC∗ = optimal cost, ϵ = least step cost
O(b1+⌊C∗/ϵ⌋)
A* evaluation function
f(n)=g(n)+h(n)
Admissible heuristic
0≤h(n)≤h∗(n)
Consistent heuristic
h(n)≤c(n,n′)+h(n′),h(goal)=0
Alpha-beta cut-offBest case about O(bm/2) nodes, worst case O(bm)
prune when α≥β

Common mistakes

  • Testing for the goal when a node is generated in UCS or A*; the cheapest path is guaranteed only when the goal is expanded.
  • Calling a heuristic admissible because it is consistent at a few edges; admissibility needs h(n)≤h∗(n) at every node.
  • Assuming admissible is enough for A* graph search; with an explored set you need consistency (or reopening of closed nodes).
  • Treating BFS as optimal when step costs differ; it minimises the number of edges, not the cost.
  • Counting pruned leaves without following the stated child order; alpha-beta results depend on left-to-right order.
  • Forgetting that DFS space is O(bm) but time is O(bm), where m can be much larger than d.

Worked examples

Try each step yourself, then reveal the working.

Example 1: A* and greedy best-first on the same graph

numerical

In the graph of the A* figure, edges are S→A (1), S→B (4), A→B (2), A→C (5), B→C (1), B→G (6), C→G (3), and h(S, A, B, C, G) =5,4,3,2,0. Run A* graph search from S. Give the order of expansion and the path found. Then do the same for greedy best-first.

  1. Step 1: Check the heuristic before trusting A*.

    Try it on paper first.

Example 2: How much extra work does iterative deepening do?

numerical

A tree has branching factor b=10 and the shallowest goal at depth d=5. Count the nodes generated (excluding the root) by BFS and by IDS in the worst case, testing for the goal on generation for BFS and ignoring the nodes BFS would generate below depth 5.

  1. Step 1: Count for BFS.

    Try it on paper first.

Example 3: Minimax value and alpha-beta pruning

numerical

A MAX root has three MIN children B, C, D. Their leaves, left to right, are B: 5, 8, 6; C: 3, 9, 7; D: 7, 2, 10. Find the minimax value and the leaves that alpha-beta (left to right) never evaluates.

  1. Step 1: Compute plain minimax first.

    Try it on paper first.

Example 4: Is the heuristic safe for A*?

conceptual

For a route-finding problem, h1 = straight-line distance to the goal and h2=2h1. Which of them guarantees an optimal route with A* graph search?

  1. Step 1: Check admissibility.

    Try it on paper first.

Previous year questions

7 official GATE DA questions on this topic, newest first.

Practise these 7 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE DA syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.