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.
1.2 Breadth-first search
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.
| Operation | Rule for an exam trace |
|---|---|
| Select | Remove the oldest frontier node |
| Expand | Append unseen successors in the specified order |
| Goal test | Use the stated generation or removal convention |
| Duplicates | State whether frontier duplicates are suppressed as well as expanded duplicates |
| Parent | First discovery gives a shortest unweighted path |
For a full tree with shallowest goal depth and branching factor , a generation-time goal test gives worst-case time and frontier space . If goals are tested on removal, earlier non-goal nodes at depth may generate depth : the common general bound is for both. These bounds count generated nodes with bounded work per successor. On an explicit finite graph, adjacency-list BFS takes time and auxiliary space, where count vertices and edges.
1.3 Depth-first and depth-limited search
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 be the maximum branching factor and the maximum search-tree depth. Depth-limited search (DLS) permits depth at most . 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 cannot find it.
| Tree-search method | Worst-case node work | Frontier/path space | Condition |
|---|---|---|---|
| DFS | Finite maximum depth , | ||
| DLS | Limit , | ||
| Recursive DFS with lazy successors | Same node work | frames | One successor at a time; no global visited set |
Here count graph vertices and edges. Graph DFS additionally stores visited states: the finite adjacency-list implementation takes time and auxiliary space. Do not apply the linear-depth tree-space claim to that visited set.
1.4 Iterative deepening
Let be the shallowest goal depth and the branching factor. Iterative-deepening DFS (IDDFS) repeats DLS with limits . 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.
1.5 Uniform-cost search
UCS removes the frontier node of least , 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.
1.6 Bidirectional search and selection guide
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.
| Need | First candidate | Main limitation |
|---|---|---|
| Fewest moves | BFS | Stores a wide frontier |
| Least nonnegative path cost | UCS | May explore many cheap routes |
| Small memory, shallow solution | IDDFS | Repeats upper levels |
| Any solution in a finite graph | DFS with visited set | No shortest-path guarantee |
| Known depth bound | DLS | Wrong bound can hide a goal |
| Known start and goal; reversible traversal | Bidirectional BFS | Needs 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.