Key ideas
A search problem has states, actions (successors), step costs, a start and a goal test. Let = branching factor, = depth of the shallowest goal, = maximum depth.
| Strategy | Expands | Complete? | Optimal? | Memory |
|---|---|---|---|---|
| BFS | shallowest first (FIFO) | yes (finite ) | fewest edges, so optimal only if all steps cost the same | |
| DFS | deepest first (LIFO) | no on infinite/cyclic graphs without a check | no | |
| Uniform-cost (UCS) | lowest path cost | yes, costs ≥ | yes | can be large |
| Iterative deepening (IDS) | DFS with limits 0, 1, 2, … | yes | fewest edges | |
| Greedy best-first | lowest | no | no | — |
| A* | lowest | yes (see below) | yes with admissible | large |
IDS repeats the shallow levels, but most nodes sit at the deepest level, so the overhead is small: for , it generates 123,456 nodes against 111,111 for a single pass (about 11% more), while memory stays that of one DFS. UCS is Dijkstra's algorithm, i.e. A* with 1. BFS may goal-test when a node is generated; UCS and A* must test when it is popped, otherwise a cheaper path found later is missed.
Heuristics. is admissible if it never overestimates the true cost ; consistent (monotone) if on every edge1 and . Summing that inequality along a path to the goal shows consistent ⇒ admissible, and since , never decreases along a path. So with a consistent , A* expands nodes in non-decreasing , pops each node with its optimal and never needs to process it twice1. With an admissible but inconsistent , A* is optimal only if a node reached again by a cheaper path is put back on the open list1; a strict expanded list can return a suboptimal path. On an infinite graph A* still finds a solution, if one exists, when is finite and every edge costs at least some 1. Good admissible heuristics come from relaxed problems (e.g. Manhattan distance for the 8-puzzle), and the maximum of several admissible heuristics is admissible and at least as informed. Weighted A* (, ) usually expands fewer nodes and returns a path costing at most 1. A* keeps every generated node, its main drawback; memory-bounded variants such as IDA* (iterative deepening on ) need memory linear in depth but re-expand nodes1.
Constraint satisfaction (CSP). Variables, domains, constraints; solved by backtracking2. Forward checking removes, after each assignment, the values of unassigned neighbours that conflict with it and backtracks when a domain empties; arc consistency (AC-3, MAC) also checks pairs of unassigned variables, so it prunes more3. Put the most critical variables first2: the one with the fewest remaining values (MRV)3, and on ties the one in the most constraints with unassigned variables (degree heuristic), whose value prunes the most other domains. Try first the value that removes the fewest values from other domains3.
Local search keeps one complete state. Hill climbing (greedy descent) moves to the best neighbour and stops at a local optimum4. Simulated annealing accepts a worse neighbour with probability : close to a random walk at high , greedy descent as 4. Tabu search keeps taking the best allowed move, even a worse one, but forbids undoing recent changes for a few steps (the tabu tenure), so it does not cycle back4. TSP 2-opt removes two edges and reconnects by reversing a segment. Beam search keeps the most probable prefixes; is greedy search, cost grows as versus for exhaustive search5. A finite beam is guaranteed optimal only if it can hold every prefix.
Games. Minimax backs up max at MAX nodes and min at MIN nodes. Alpha–beta prunes branches that cannot change the decision, so it returns the same value and move6. With perfect move ordering the leaf count follows , about instead of , and iterative deepening supplies good ordering6. As an AND/OR tree, MAX needs one good move (OR node) that works against every MIN reply (AND node).
Planning (STRIPS). Each action has , , . Forward (progression) planning picks the first action first; backward (regression) planning picks the last action first; a partial-order planner commits to an order only when forced7. It starts from a dummy start action (achieves the initial state) and finish action (preconditions = goal), keeps causal links , and resolves a threat (an action that may undo between them) by ordering it before or after 7. The Sussman anomaly (C on A; goal A on B and B on C) defeats planners that finish one subgoal before starting the other: whichever subgoal is achieved first must be undone to achieve the second8.
Formulas
Regression of goal through a relevant action (, )7:
Worked example
Edges S→A (2), S→B (5), A→B (1), B→G (3); , , , . True costs to G are 6, 4, 3, 0, so is admissible, but : not consistent. A* with a strict expanded list: pop S; push A () and B (). Pop B, push G (). Pop A, push S–A–B (, ); when it is popped, B is already expanded, so it is dropped. Pop G and return cost 8, while S–A–B–G costs 6. Re-opening B (non-strict list) gives the optimum.
Common pitfalls
- BFS is not cost-optimal when step costs differ — it minimises the number of edges.
- Admissible + strict expanded list can fail; it needs a consistent heuristic1.
- UCS cannot goal-test on generation, unlike BFS.
- Alpha–beta never changes the answer — only how many leaves are evaluated; bad ordering just prunes less6.
- Forward checking ≠ arc consistency: forward checking only looks at neighbours of the variable just assigned3.
- A wider beam costs more and usually finds an equally or more probable output5, but it is not guaranteed to: the extra prefixes can crowd out the one that led to the narrower beam's answer.
- Regression adds preconditions and removes achieved goals — and the action must not delete any other goal7.
References
- Wikipedia: A* search algorithm — Description (Pseudocode remark; Special cases); Properties (Termination and completeness; Admissibility); Bounded relaxation; Complexity (Space complexity)
- Wikipedia: Backtracking — Introduction; Examples — Constraint satisfaction (variable ordering)
- Wikipedia: Look-ahead (backtracking) — Look ahead techniques; Use of look ahead
- Poole & Mackworth, Artificial Intelligence — Foundations of Computational Agents, 3rd ed. (2023) — Sec. 4.6 Local Search (4.6.1 Iterative Best Improvement; 4.6.3 Local Search Variants — tabu search, Simulated Annealing)
- Dive into Deep Learning — Sec. 10.8 Beam Search (10.8.1 Greedy Search; 10.8.2 Exhaustive Search; 10.8.3 Beam Search)
- Wikipedia: Alpha–beta pruning — Core idea; Improvements over naive minimax
- Poole & Mackworth, Artificial Intelligence — Foundations of Computational Agents, 3rd ed. (2023), Ch. 6 Deterministic Planning — Sec. 6.3 Regression Planning; Sec. 6.5 Partial-Order Planning
- Wikipedia: Sussman anomaly — Introduction (the problem and both subgoal orders)