∑GATE DA Atlas

Problem Solving by Search — Uninformed Strategies

Formulating problems as state-space search (states, actions, transition model, goal test, path cost), tree search vs graph search, measuring strategies by completeness, optimality, time and space, and the uninformed strategies — breadth-first, uniform-cost, depth-first, depth-limited, iterative deepening and bidirectional search — traced on an example graph.

Section 79 practice questions

Search problems

Many AI tasks — route finding, puzzles, planning, theorem proving — are solved by searching through a space of states. A search problem is defined by:

ComponentExample (route finding)
Initial statein city S
Actions ACTIONS(s)\text{ACTIONS}(s)drive along a road out of ss
Transition model RESULT(s,a)\text{RESULT}(s, a)the city at the other end
Goal testin city G?
Path cost (sum of step costs c(s,a,s′)c(s, a, s'))total kilometres

A solution is a sequence of actions from the initial state to a goal; an optimal solution has the lowest path cost.

Search builds a tree of nodes (state + parent + action + path cost gg + depth). The frontier (open list) holds generated but unexpanded nodes; strategies differ only in which frontier node they expand next.

  • Tree search may revisit the same state many times (and loop forever on cycles).
  • Graph search keeps an explored (closed) set and skips repeated states.
Python
from collections import deque

def bfs(start, goal, succ):
    frontier = deque([[start]])
    explored = {start}
    while frontier:
        path = frontier.popleft()
        if path[-1] == goal:
            return path
        for nxt in succ(path[-1]):
            if nxt not in explored:
                explored.add(nxt)
                frontier.append(path + [nxt])
    return None

Measuring a strategy

  • Complete: guaranteed to find a solution when one exists?
  • Optimal: guaranteed to find a least-cost solution?
  • Time and space, in terms of the branching factor bb, the depth of the shallowest goal dd, and the maximum depth mm.

The uninformed strategies

Uninformed (blind) strategies use only the problem definition — no estimate of distance to the goal.

StrategyFrontierCompleteOptimalTimeSpace
Breadth-first (BFS)FIFO queueyes (bb finite)yes if step costs equalO(bd)O(b^d)O(bd)O(b^d)
Uniform-cost (UCS)priority queue on g(n)g(n)yes if costs ≥ϵ>0\ge \epsilon > 0yesO(b1+⌊C∗/ϵ⌋)O(b^{1 + \lfloor C^*/\epsilon\rfloor})same
Depth-first (DFS)LIFO stackno (infinite paths)noO(bm)O(b^m)O(bm)O(bm)
Depth-limited (limit ℓ\ell)stack, cut at depth ℓ\ellno if ℓ<d\ell < dnoO(bℓ)O(b^\ell)O(bℓ)O(b\ell)
Iterative deepening (IDDFS)DLS with ℓ=0,1,2,…\ell = 0, 1, 2, \dotsyesyes if step costs equalO(bd)O(b^d)O(bd)O(bd)
Bidirectional (BFS both ways)two queuesyesyes if step costs equalO(bd/2)O(b^{d/2})O(bd/2)O(b^{d/2})

(C∗C^* is the optimal cost and ϵ\epsilon the smallest step cost.)

Expands the shallowest node first; finds the solution with the fewest steps. Memory is the real problem: at b=10b = 10, d=10d = 10 it stores 101010^{10} nodes.

Expands the node with the lowest path cost g(n)g(n) — Dijkstra's algorithm on an implicit graph (see shortest paths). To be optimal, the goal test must be applied when a node is selected for expansion, not when it is generated; a cheaper path to an already-generated node replaces the costlier one.

Depth-first search and its fixes

DFS dives down one branch and backtracks — tiny memory, but it can wander down an infinite path or return a poor solution. Depth-limited search cuts it off at depth ℓ\ell; iterative deepening repeats DLS with growing limits, combining BFS's completeness and optimality (for unit costs) with DFS's memory. Re-generating the shallow levels is cheap because most nodes are at the deepest level.

BFS order 1 2 3 4 5 6 7 DFS order 1 2 5 3 4 6 7 BFS: level by level (queue) · DFS: deepest first (stack)
The same tree expanded in breadth-first and depth-first order.

Quick revision

Practice questions

GATE-style questions: 2 one-mark and 7 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.

Q1MCQ2 marks

Directed graph with step costs (neighbours are generated in alphabetical order): S→A (1), S→B (4), A→C (2), A→D (5), B→D (1), C→G (6), D→G (2). Start S, goal G. Graph search is used (a state is not added again once generated/expanded), and the goal test is applied when a node is expanded.

In which order does uniform-cost search expand the nodes?

Q2NAT2 marks

Directed graph with step costs (neighbours are generated in alphabetical order): S→A (1), S→B (4), A→C (2), A→D (5), B→D (1), C→G (6), D→G (2). Start S, goal G. Graph search is used (a state is not added again once generated/expanded), and the goal test is applied when a node is expanded.

The cost of the path to G returned by uniform-cost search is ______.

Q3NAT2 marks

Directed graph with step costs (neighbours are generated in alphabetical order): S→A (1), S→B (4), A→C (2), A→D (5), B→D (1), C→G (6), D→G (2). Start S, goal G. Graph search is used (a state is not added again once generated/expanded), and the goal test is applied when a node is expanded.

The cost of the path to G returned by breadth-first search is ______.

Q4MCQ1 mark

Which uninformed strategy is complete and optimal for unit step costs while using only O(bd)O(bd) memory?

Q5NAT2 marks

A search tree has branching factor b=10b = 10. The number of nodes generated at depths 1, 2 and 3 combined (excluding the root) is ______.

Q6MSQ2 marks

Which statements about uninformed search are correct (finite branching factor bb, solution depth dd)?

One or more options are correct.

Q7NAT2 marks

Iterative deepening search with b=10b = 10 reaches a goal at depth d=5d = 5 (in the worst case, on the last node of depth 5). Nodes at depth ii are generated (d+1−i)(d + 1 - i) times. The total number of node generations, ∑i=1d(d+1−i) bi\sum_{i=1}^{d}(d + 1 - i)\,b^i, is ______.

Q8MCQ1 mark

The space complexity of depth-first (tree) search with branching factor bb and maximum depth mm is

Q9MCQ2 marks

Bidirectional search runs a forward search from the start and a backward search from the goal (both breadth-first) until they meet. Its time complexity is