Chapter 1

Uninformed search

A state describes the problem; a search node records one route to that state. Frontier ordering decides which route is examined next. Before tracing, fix the goal-test timing, successor order and duplicate policy.

1.1 States, nodes and costs

Specify the initial state, legal actions, successor function, goal test and action costs. A node also stores its parent and path cost. Two nodes can contain the same state but different paths. A complete algorithm finds a solution whenever one exists under its stated assumptions; an optimal algorithm returns a least-cost solution.

Tree search stores paths and may revisit a state. Graph search detects repeated states. For unweighted BFS, marking a state when first enqueued is safe. For UCS or A*, keep its best known cost and update a cheaper route. A global visited set and a current-path cycle check are different: the latter saves memory but permits rediscovery on another path.

Past papers · DA 2024–2026 (3 papers): 1 question, 2 marks

BFS uses a FIFO queue and visits nodes by nondecreasing depth. With finite branching it reaches every finite-depth goal. It minimises the number of edges; it minimises path cost when each edge has the same nonnegative cost. A visited set avoids repeated states in a finite graph.

OperationRule for an exam trace
SelectRemove the oldest frontier node
ExpandAppend unseen successors in the specified order
Goal testUse the stated generation or removal convention
DuplicatesState whether frontier duplicates are suppressed as well as expanded duplicates
ParentFirst discovery gives a shortest unweighted path

For a full tree with shallowest goal depth dd and branching factor b>1b>1, a generation-time goal test gives worst-case time and frontier space O(bd)O(b^d). If goals are tested on removal, earlier non-goal nodes at depth dd may generate depth d+1d+1: the common general bound is O(bd+1)O(b^{d+1}) for both. These bounds count generated nodes with bounded work per successor. On an explicit finite graph, adjacency-list BFS takes O(nv+ne)O(n_v+n_e) time and O(nv)O(n_v) auxiliary space, where nv,nen_v,n_e count vertices and edges.

DFS uses a LIFO stack, or recursive calls, to follow a branch before its siblings. To visit alphabetical successors using a stack, push them in reverse alphabetical order. DFS is not optimal. Tree DFS can loop on a cycle or follow an infinite branch; graph DFS with a visited set is complete on a finite reachable graph.

Let bb be the maximum branching factor and mm the maximum search-tree depth. Depth-limited search (DLS) permits depth at most ℓ\ell. Test for a goal at the limit before cutting off. Return cutoff when a deeper search might help; return failure when no solution remains in the searched finite subtree. A limit below the shallowest solution depth dd cannot find it.

Tree-search methodWorst-case node workFrontier/path spaceCondition
DFSO(bm)O(b^m)O(bm)O(bm)Finite maximum depth mm, b>1b>1
DLSO(bℓ)O(b^\ell)O(bℓ)O(b\ell)Limit ℓ\ell, b>1b>1
Recursive DFS with lazy successorsSame node workO(m)O(m) framesOne successor at a time; no global visited set

Here nv,nen_v,n_e count graph vertices and edges. Graph DFS additionally stores visited states: the finite adjacency-list implementation takes O(nv+ne)O(n_v+n_e) time and O(nv)O(n_v) auxiliary space. Do not apply the linear-depth tree-space claim to that visited set.

1.4 Iterative deepening

Let dd be the shallowest goal depth and bb the branching factor. Iterative-deepening DFS (IDDFS) repeats DLS with limits 0,1,…,d0,1,\ldots,d. Restart the search state for each limit. It is complete with finite branching and is optimal for equal nonnegative edge costs. It has BFS's shallow-goal property with DFS's small path memory.

UCS removes the frontier node of least g(n)g(n), the accumulated path cost. Update a state's best cost when a cheaper route appears. Test a goal when its best entry is removed, not when it is first generated. On a finite graph with nonnegative edge costs, this is Dijkstra's selection rule stopped at a goal.

Finite branching and the positive cost bound ensure completeness even on an infinite state space with a finite-cost solution. Nonnegative costs suffice on a finite graph with duplicate handling. Infinitely many zero-cost states can prevent termination on an infinite graph. Negative edges invalidate the usual optimality argument.

Bidirectional BFS searches forward from the start and backward from a known goal, using predecessor edges in the backward direction. For equal-cost edges and roughly balanced branching, each side needs about half the solution depth. Expand by layers and apply a valid meeting/termination rule; an arbitrary first frontier overlap in an uneven or weighted search is insufficient.

NeedFirst candidateMain limitation
Fewest movesBFSStores a wide frontier
Least nonnegative path costUCSMay explore many cheap routes
Small memory, shallow solutionIDDFSRepeats upper levels
Any solution in a finite graphDFS with visited setNo shortest-path guarantee
Known depth boundDLSWrong bound can hide a goal
Known start and goal; reversible traversalBidirectional BFSNeeds correct backward search and meeting rule

Last-minute recall

  • A state is a configuration; a search node is a path record.
  • BFS chooses depth; UCS chooses accumulated cost.
  • Test UCS goals on removal of a best-cost entry.
  • DFS tree-space bounds exclude a global visited set.
  • DLS cutoff and failure are different outcomes.
  • IDDFS is cost-optimal only under the appropriate equal-cost assumption.
  • Infinite zero-cost regions can defeat UCS completeness.
  • Expansion counts depend on goal-test and duplicate conventions.

Revise offline: the whole Artificial Intelligence handbook as one PDF

37 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections