Uninformed and Informed Search

Learn how an AI agent finds a way to its goal when there are far too many possibilities to try them all. Turn a problem into a state space, then compare breadth-first, uniform-cost, depth-first and iterative deepening search by what they guarantee and what they cost. Use heuristic estimates to search smarter with greedy best-first search and A*, design heuristics that keep A* optimal, and solve huge optimization problems with hill climbing, simulated annealing and genetic algorithms. Worked examples trace the main algorithms on small maps, puzzles and n-queens boards; the other methods are explained through their procedures and comparisons.

IntermediateLesson 2 of 10 in Artificial Intelligence Course

What you will learn

  1. Turn a problem into a state space that an algorithm can explore, follow how the general search procedure grows a search tree, and compare algorithms by completeness, cost optimality, time and memory.
    • Describe a search problem and its state space
      Name the parts of a search problem, picture its state space as a graph, choose a useful level of abstraction and estimate how large the space is.
    • Grow a search tree with the general search algorithm
      Use nodes, the frontier and the set of reached states to explain how a search algorithm expands a search tree, avoids repeated work and recovers the solution path.
    • Measure and compare search algorithms
      Judge any search algorithm by completeness, cost optimality, time and space, express its cost with the parameters b, d, m, C* and ε, and see why exponential growth limits uninformed search.
  2. Run breadth-first, uniform-cost, depth-first and iterative deepening search by hand, explain each one's guarantees and costs, and choose the right strategy for a problem.
    • Run breadth-first search
      Explore a state space layer by layer with a FIFO queue, trace it on a small map, and state when it is complete and cost-optimal.
    • Find the cheapest path with uniform-cost search
      Expand nodes in order of path cost with a priority queue, trace the algorithm, and explain why it is cost-optimal and what it costs.
    • Save memory with depth-first and iterative deepening search
      Trace depth-first search, use a depth limit, and explain how iterative deepening combines the memory use of depth-first search with the guarantees of breadth-first search.
    • Compare uninformed strategies and choose one
      Compare the uninformed strategies side by side, add bidirectional search, and pick a suitable strategy for a given problem.
  3. Use a heuristic estimate to steer the search, trace greedy best-first search and A*, prove when A* is optimal, and use variants that trade optimality for speed or memory.
    • Use a heuristic with greedy best-first search
      Define a heuristic function, trace greedy best-first search, and explain why it is fast but can return a poor solution.
    • Find optimal paths with A* search
      Trace A* with f = g + h, explain why an admissible heuristic makes it cost-optimal, and see how a better heuristic prunes the search.
    • Trade optimality for speed or memory
      Use weighted A*, beam search and memory-bounded versions of A* such as IDA* when plain A* is too slow or needs too much memory, and state what each gives up.
  4. Test a heuristic for admissibility and consistency, invent admissible heuristics from relaxed problems and subproblems, and compare heuristics by dominance and effective branching factor.
    • Test heuristics for admissibility and consistency
      Check whether a heuristic never overestimates and obeys the triangle inequality, and explain why each property matters for A*.
    • Invent admissible heuristics from relaxed problems
      Derive heuristics by removing restrictions from a problem, compute them for the 8-puzzle, and build stronger ones from subproblems and by combining heuristics.
    • Compare heuristics by dominance and effective branching factor
      Decide which of two heuristics is better using dominance, measure a heuristic with the effective branching factor, and weigh accuracy against the cost of computing it.
  5. Solve optimization problems by moving through a landscape of complete states, use hill climbing and its variants, and escape local optima with simulated annealing and population methods.
    • Describe local search and the state-space landscape
      Explain when the path does not matter, formulate a problem with complete states, and describe the landscape features that make local search hard.
    • Climb toward better states with hill climbing
      Run steepest-ascent hill climbing, recognize where it gets stuck, and improve it with sideways moves, random choices, random restarts and local beam search.
    • Escape local optima with simulated annealing and genetic algorithms
      Accept some worse moves with a probability that falls as the temperature drops, design a cooling schedule, and use populations with crossover and mutation.

Uninformed and Informed Search study guide

5 chapters

1

Frame problems as search and judge search algorithms

A search algorithm needs a precise description of what can happen and what counts as success. A route map and a sliding puzzle look different, but both can be described with states, actions, goals and costs. The search then builds paths through that space. Distinguishing a state from a search node makes duplicate handling clear; distinguishing completeness from cost optimality makes algorithm comparisons meaningful.

1.1 Describe a search problem and its state space

A search problem describes choices before an algorithm starts making them. Its formulation controls both what a solution means and how many possibilities the algorithm must consider.

Define the problem

There are six parts:

  • States describe the possible situations.
  • The initial state is where the search begins.
  • Actions are the choices available in a state.
  • The transition model, RESULT(s,a), gives the state after action a.
  • The goal test recognizes an acceptable state.
  • The action cost function, c(s,a,s′), assigns a cost to each step.

All action costs here are positive. A solution to a path-finding problem is an action sequence leading to a goal. Add its action costs to obtain its path cost. A cost-optimal solution minimizes that sum. Merely naming the destination does not tell an agent how to reach it.

Formulate the 8-puzzle

A board contains eight numbered tiles and a blank. Record all nine positions as the state. The initial state is the supplied layout; the goal is "1 2 3 / 4 5 6 / 7 8 blank". An action moves the blank left, right, up or down when that move stays on the board. The transition swaps the blank with the neighboring tile, and every move costs 1. A corner permits two actions; the center permits four.

A solution is a sequence such as "Left, Up, Right", if those moves are legal and reach the goal. Because each move has the same cost, minimizing cost means minimizing the number of moves.

Choose the state space

Think of states as vertices in a directed graph and actions as cost-labeled edges. A two-way road gives two directed edges. For route finding, a state can be the current place and a step cost can be road distance in kilometers.

Abstraction leaves out irrelevant detail. The music playing in a car need not be part of a route state. An abstract solution must still be possible to carry out. Removing a detail that changes which actions are legal would change the problem, not just simplify its description.

The formulation can save more work than a faster queue. Placing eight queens on any empty squares gives 64×63×⋯×57≈1.8×1014 possible ordered placement sequences. Placing each next queen in the leftmost empty column on an unattacked square leaves 2,057 reachable states. These are different constructions of the same goal condition.

Generate possibilities as needed

The 8-puzzle has 9!/2=181,440 reachable states from a fixed start. The 15-puzzle has 16!/2≈1.05×1013. A complete 8-queens representation with one queen per column has 88=16,777,216 states.

Such spaces are usually supplied implicitly: the search receives a start state and procedures for actions and transitions. It generates the relevant portion as it runs. For a path problem, retain the action sequence. For an optimization problem such as queen placement, the final arrangement itself can be the answer.

Key Takeaways

  • A search problem specifies states, a start, actions, transitions, a goal test and action costs.
  • A path solution is an action sequence; its cost is the sum of its step costs.
  • An abstraction must preserve the ability to carry out its solutions.
  • An implicit state space is generated from actions and transitions as needed.
  • The formulation can greatly reduce the number of states or paths considered.

1.2 Grow a search tree with the general search algorithm

The state space describes what is possible. The search tree records the paths the algorithm has tried. Several nodes can describe the same state because they arrived there by different paths.

Store a path in a node

A node stores a state, its parent node, the action from that parent and the path cost g(n). Depth may also be stored. The root has no parent and path cost 0. Expanding a node applies every legal action to its state and generates its children.

On a two-way map, paths "S, A" and "S, B, C, A" end in the same state but give different nodes. Even a finite map can generate an infinite search tree: "S, A, S, A, …" keeps producing longer paths.

The frontier, also called the fringe, holds generated nodes awaiting expansion. The reached set records generated states and the best node found for each. It includes states still on the frontier as well as states already expanded. A closed or explored set usually refers only to expanded states.

Run the general best-first procedure
  1. Put the root in the frontier and reached table.
  2. If the frontier is empty, return failure.
  3. Remove the node with the smallest evaluation value f(n).
  4. If its state is a goal, return that node.
  5. Expand it. Add each new state; for a previously reached state, replace its stored node only when the new path is cheaper.
  6. Repeat from step 2.

A cheaper path to an already expanded state may require reopening it. Equal-cost returns add no improvement. With a heap, an old entry can remain physically present; it must be recognized as stale and skipped when removed.

The frontier rule controls the strategy. A FIFO queue selects shallow nodes for BFS. A LIFO stack selects deep nodes for DFS. Priority queues ordered by g, h and g+h give uniform-cost, greedy best-first and A* search.

Follow the road-map nodes

Use these two-way roads, with distances in kilometers: S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2. Start at S and seek G. Break ties alphabetically.

Expanding S generates A with cost 2, B with cost 3 and D with cost 9. Each has parent S. The frontier contains A, B and D; the reached table also contains S. Later, C can be reached through A for cost 6 or through B for cost 4. Those are two nodes for one state, and the cheaper one should represent C.

To recover a solution, follow the returned goal node's parent links backward and reverse the actions. Updating the cost without updating the parent would leave a path that disagrees with its reported cost.

Decide what to remember

Graph search remembers reached states to avoid repeated work. Tree-like search has no global reached table; it may only reject cycles on the current path. It saves memory but can generate the same state through many paths.

The general procedure tests goals on removal. BFS can test at generation because generation follows depth order. Cost-based search must wait for removal: the first generated goal can have a more expensive path than a goal found later.

Key Takeaways

  • A state is a situation; a node represents a path to a state.
  • The frontier holds generated, unexpanded nodes; the reached table also remembers expanded states.
  • Keep a cheaper path to a state, including its matching parent link.
  • Graph search saves repeated work; tree-like search saves memory.
  • UCS and A* test a goal when it is removed from the frontier.
  • Parent links recover the action sequence from the returned goal node.

1.3 Measure and compare search algorithms

An algorithm can be reliable yet too expensive to run. Judge its guarantees separately from its resource use, then check whether those guarantees match the problem you actually need to solve.

Ask four different questions

Completeness means finding a solution whenever one exists. In a finite reachable space, exhausting all possibilities can also prove failure. An infinite space with no solution may be searched forever, even by a complete algorithm.

Cost optimality means returning a solution with the lowest path cost. It says nothing about how fast the algorithm runs. A method can find a solution reliably while returning an expensive route.

Time complexity counts generated or expanded nodes. State which count is being used when comparing measurements. Space complexity measures the maximum number of nodes held at once, including the frontier and stored search information.

Identify the parameters

For an implicit search space, use:

SymbolMeaning
bMaximum branching factor: successors per node
dDepth of a shallowest solution
mMaximum path depth, possibly infinite
C∗Cost of an optimal solution
ϵPositive lower bound on action cost

For an explicit graph already in memory, vertex and edge counts are usually more useful. A traversal bound in ∣V∣ and ∣E∣ answers a different question from a bound for generating an unseen tree.

See why depth is expensive

A full tree through depth d contains

1+b+b2+⋯+bd=bd+1−1b−1

nodes for b≠1. With branching factor 10 and depth 5, that is 111,111 nodes including the root. Increasing the depth by one adds a layer with ten times as many nodes as the previous layer.

At one million nodes per second and 1 kilobyte per node, the scale changes quickly:

DepthApproximate nodesTimeMemory
61.1 million1 second1.1 GB
8111 million2 minutes111 GB
1011 billion3 hours11 TB
121.1 trillion13 days1.1 PB

These are decimal storage units: 1 GB is 109 bytes. Memory can rule out a search long before its running time seems unreasonable.

Read guarantees with their conditions

BFS eventually reaches every finite depth when branching is finite. DFS can spend forever on one infinite branch and never try a nearby goal. That difference explains their completeness results.

BFS finds a path with the fewest actions. If a two-step route costs 11 km and a three-step route costs 9 km, the shallower route is not cost-optimal. Equal step costs make depth and cost agree; different costs can separate them.

A worst-case big-O bound does not predict every run. Two methods with the same bound may differ in constants, duplicate handling and the number of useful branches. A heuristic can greatly improve a typical run without removing the exponential worst case.

Key Takeaways

  • Completeness concerns finding a solution; cost optimality concerns the cost of the returned solution.
  • An infinite space without a solution need not lead to a terminating failure report.
  • Branching factor and depth explain the exponential growth of implicit search trees.
  • Measure peak memory as well as node counts; storage is often the first limit.
2

Search without domain knowledge

Without a heuristic, a search must choose what to explore using depth or cost already paid. A queue, a stack and a cost-ordered priority queue can therefore produce very different routes on the same map. Trace their frontier changes to see why their guarantees differ. Iterative deepening saves memory by repeating shallow work, while bidirectional search can reduce depth when the goal and reverse actions are available.

Breadth-first search explores in layers. Its next expansion is the shallowest node still waiting, so every one-action path is considered before any two-action path is expanded.

Keep the queue in order

The frontier is first in, first out: remove from the front and append children at the back. Record states when they are generated. If a child state has already been reached, skip it; otherwise two different parents could put the same state into the queue.

Test the initial state before searching. For later nodes, BFS can use an early goal test on generation. The first generated goal has minimum depth because the algorithm generates children layer by layer. The order within a layer can choose between equally shallow solutions, but cannot make a deeper solution appear first.

Trace the example map

The two-way roads are S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2 km. Start at S, seek G and generate neighbors alphabetically. In the table, the next node to remove is on the left.

Expanded nodeNewly reached statesQueue afterward
SA, B, DA, B, D
ACB, D, C
BNoneD, C
DG, which passes the goal testSearch stops

When B is expanded, C and D are already reached. They do not move to new positions in the queue. When D generates G, its parent chain is G–D–S. Reverse it to recover S–D–G, with two roads and total distance 9+2=11 km.

C has already been generated, but it has not been expanded. Its route to G would have three roads. BFS can stop without exploring it because three roads cannot improve the number of actions in a two-road solution.

Know what the result minimizes

BFS is complete for finite branching, even if the space is infinite: each finite layer is processed before the next. It is cost-optimal when all actions cost the same. In a sliding puzzle with cost 1 per move, a shallowest solution is also a cheapest solution.

On this road map, S–B–C–G costs 3+1+5=9 km. BFS returns the 11-km route because distance is not its ordering rule. "Shortest path" therefore needs a unit: fewest roads and fewest kilometers are different objectives.

Account for memory

With early goal testing, BFS takes O(bd) time and space. It may generate nearly every node through the goal depth and retain the frontier plus reached information. If goals are tested only on removal, expanding other nodes at depth d can generate depth d+1, giving the usual O(bd+1) bound for that version.

With branching factor 10 and 1 kilobyte per node, storing a tree through depth 10 takes about 11 TB. BFS is useful for shallow, equal-cost problems when enough memory is available, such as minimum-hop network paths or fewest-move puzzles. A FIFO queue does not use the numerical edge costs, even when they are written on the graph.

Key Takeaways

  • BFS expands the shallowest node using a FIFO queue.
  • Record reached states at generation to avoid duplicate queue entries.
  • The first generated goal has the fewest actions.
  • Equal action costs make BFS cost-optimal.
  • With early goal testing, time and space are O(bd).

Uniform-cost search orders paths by the cost already paid. It can pass over a nearby but expensive destination while it investigates longer routes made of cheap steps.

Remove the cheapest path

Set f(n)=g(n) and use a priority queue. When an expansion finds a cheaper path to a reached state, update both its cost and its parent. An equal-cost path does not improve the record. UCS is the search form of Dijkstra's algorithm, stopping when it removes a goal.

The late goal test is essential. Generating a goal proves that a route exists. Removing that goal as the cheapest frontier node proves that no unfinished cheaper route can beat it, given positive action costs.

Trace the example map

Use the two-way roads S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2 km. Break cost ties alphabetically. The frontier entries below show state and path cost.

Removed nodeUpdateFrontier afterward
S, 0Reach A, B, DA 2; B 3; D 9
A, 2Reach C via AB 3; C 6; D 9
B, 3Improve C through BC 4; D 9
C, 4Reach GD 9; G 9
D, 9G via D costs 11; keep 9G 9
G, 9Goal test succeedsReturn

The replacement of C is decisive: 3+1=4 beats 2+4=6. G's parent is C, C's parent is B and B's parent is S. The returned route S–B–C–G costs 9 km. D is removed before G only because the tie rule is alphabetical.

If a direct S–G road of 12 km were added, S would generate a goal immediately. An early test would return 12 km before discovering the 9-km route. The priority queue cannot protect optimality if the stopping rule bypasses it.

Explain the guarantee

With finite branching and every action cost at least some ϵ>0, only finitely many path steps can fit below any fixed cost bound. UCS therefore eventually removes a goal whenever one exists. Positive costs ensure that extending a path cannot make it cheaper, which supports the optimality proof.

Zero costs need care. Tree-like search can keep circling a zero-cost cycle. Graph search rejects equal-cost returns to the same state, but an infinite chain of distinct states with bounded accumulated cost can still delay a goal forever. Negative step costs break the ordinary UCS optimality argument.

Understand the expense

The standard worst-case time and space bound is O(b1+⌊C∗/ϵ⌋). On this map, C∗=9 and ϵ=1, giving O(b10). This is a loose bound, not the actual number expanded on the six-state map.

Many cheap dead-end paths can force UCS to do substantial work before taking one costly useful action. When all step costs are equal, its late goal test gives the familiar O(bd+1) bound. A* with h=0 makes exactly the same priority comparisons as UCS.

Key Takeaways

  • UCS orders the frontier by accumulated path cost g.
  • Return a goal on removal, when it is the cheapest pending path.
  • Replace a more expensive route to a reached state, including its parent.
  • Finite branching and a positive lower bound on step costs give completeness.
  • UCS is cost-optimal under the positive-cost model.

Depth-first search follows one branch before trying its alternatives. That choice can greatly reduce memory, but it lets an unlucky branch delay every other possibility.

Follow a deep branch

DFS uses a last in, first out stack. In a tree-like version, reject states already on the current path to avoid immediately cycling. Store the current path and the unexpanded siblings along it. To try successors alphabetically with a stack, push them in reverse alphabetical order.

On the two-way map S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2 km, start at S and seek G. Trying neighbors alphabetically and testing goals on removal gives S, A, C, B, D, G. At C, B is the first neighbor not already on the path. The returned route S–A–C–B–D–G costs 2+4+1+6+2=15 km.

DFS is not cost-optimal. It is complete in a finite space with path cycle checks, but can follow an infinite branch forever. Its worst-case time is O(bm) and its stored paths and siblings need O(bm) space. Backtracking that generates one child at a time reduces storage to O(m). With branching 10 and maximum depth 12, path-and-sibling storage is about 120 nodes, compared with roughly a trillion for BFS through depth 12. A global reached table would use additional memory.

Bound the depth

Depth-limited search stops expanding at depth ℓ. A goal there can still be recognized. It distinguishes three outcomes:

  • A solution was found.
  • Cutoff: the depth bound prevented a full search.
  • Failure: the relevant possibilities were exhausted without a goal or cutoff.

A cutoff does not prove that no solution exists. If the shallowest goal is at depth 7, a limit of 5 cannot reach it. Worst-case time and space are O(bℓ) and O(bℓ).

Increase the limit gradually

Iterative deepening search, or IDS, runs depth-limited searches with limits 0, 1, 2 and so on. It finds a shallowest solution without storing a breadth-first frontier. With finite branching it is complete; with equal action costs it is cost-optimal. Time is O(bd) and space is O(bd).

Most nodes of a broad tree are in the last layer, so repeating the upper layers is often inexpensive. For b=10 and d=5, count generated nodes below the root:

5(10)+4(100)+3(1,000)+2(10,000)+100,000=123,450.

BFS generates 111,110 such nodes through depth 5. IDS does about 11% more generation while keeping only depth-first storage. The repeated root visits are excluded from both of these particular counts.

For branching factors greater than 1, the broad-tree overhead approaches the factor b/(b−1). This advantage is weaker for a narrow chain, where repeated prefixes dominate. IDS is a useful uninformed choice when solution depth is unknown and a full frontier will not fit. In spaces with many routes to the same state, its lack of a global reached set can cause substantial regeneration.

Key Takeaways

  • DFS uses little path storage but can miss a goal forever on an infinite branch.
  • Path cycle checks prevent returns to ancestors without a global reached table.
  • A depth cutoff means the limit blocked further search, not that the problem has no solution.
  • IDS increases the depth limit until a shallowest solution is found.
  • IDS is complete for finite branching and cost-optimal for equal step costs.
  • IDS trades repeated generation for O(bd) space.

2.4 Compare uninformed strategies and choose one

A useful strategy matches the result you need and the resources you have. Uninformed search uses the problem definition without an estimate of the remaining distance. It can still be systematic and carefully ordered.

Compare like with like

Assume finite branching and the positive-cost conditions for UCS. The BFS row uses early goal testing; the DFS row uses path cycle checks and no global reached table.

StrategyComplete?Cost-optimal?TimeSpace
BFSYesEqual step costsO(bd)O(bd)
UCSYes, costs bounded below by positive ϵYesO(b1+⌊C∗/ϵ⌋)Same as time
DFSIn finite spacesNoO(bm)O(bm)
Depth-limitedIf the limit reaches a goal depthNoO(bℓ)O(bℓ)
IDSYesEqual step costsO(bd)O(bd)

BFS and IDS also minimize cost when cost is a nondecreasing function of depth alone. The word "alone" matters: all paths of a given depth must have the same cost for this broader condition. Positive edges by themselves do not make BFS cost-optimal.

Search from both ends

Bidirectional search works forward from the start and backward from the goal. If the searches meet near the middle, each reaches roughly depth d/2. The work is then roughly 2bd/2 instead of bd. With branching factor 10 and solution depth 6, the leading-layer comparison is about 2,000 nodes versus 1,000,000.

It needs an explicit goal state and a way to generate predecessors. Reversible two-way roads make backward expansion easy. A goal property such as "all queens are safe" may describe too many goal states to provide a convenient reverse starting point.

With breadth-first or cost-based searches, suitable meeting and termination rules can preserve completeness and optimality. On a weighted map, stop only once no cheaper connection remains possible. The first overlap between the two searches need not be the cheapest connection.

Choose by the problem

For the fewest moves in a small sliding puzzle, equal move costs make BFS appropriate if memory is ample. For minimum-distance travel with unequal road lengths and no heuristic, choose UCS. For an enormous equal-cost puzzle of unknown solution depth, IDS avoids an enormous frontier. In a finite space with many deep goals where any solution is acceptable, DFS can be practical. A known start and goal with reversible actions makes bidirectional search worth considering.

Memory use must include what the chosen version stores. DFS with a global reached table no longer has the same storage profile as tree-like DFS. A late-goal BFS trace should not be compared with an early-goal complexity bound as if the versions were identical.

Even the best uninformed choice can face exponential growth. When useful domain knowledge is available, a heuristic can reduce irrelevant exploration. When only a final configuration matters, local search can avoid keeping a search tree.

Key Takeaways

  • Choose a strategy using the desired objective, cost structure, memory and solution depth.
  • Bidirectional search needs a goal to start from and a way to generate predecessors.
  • An early meeting is not a safe weighted-search stopping rule.
  • Fewest actions and cheapest path agree for equal action costs.
3

Search with heuristics: greedy best-first search and A*

A heuristic estimates the work still needed to reach a goal. Greedy search follows that estimate directly; A* combines it with the cost already paid. Comparing their traces shows why guidance can save expansions and why the wrong estimate can hide a cheap route. When ordinary A* needs too much time or memory, its variants make different trades between solution quality, storage and repeated work.

A heuristic assigns a state an estimate of the cheapest remaining cost to a goal. Write it as h(n) for the state in node n. It depends on the state, not the path used to reach it, and is zero at a goal.

Estimate what remains

Straight-line distance estimates remaining road distance. On a grid with horizontal and vertical unit moves, Manhattan distance adds coordinate differences:

h=∣x1−x2∣+∣y1−y2∣.

From cell (1,1) to (4,5), this gives 3+4=7 moves. Straight-line distance between the same coordinates is 32+42=5. The estimates answer different relaxed movement questions. A heuristic must match the units of the cost it estimates; kilometers do not directly estimate travel time without a suitable conversion model.

Informed search uses an estimate to guide expansion. The estimate need not tell the algorithm which action to take. It scores the states produced by the legal actions, and the frontier rule decides which pending path to investigate next.

Follow the smallest estimate

Greedy best-first search sets f(n)=h(n). Its priority queue removes the state that looks closest to the goal, ignoring the cost already paid.

Use the two-way roads S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2 km. The heuristic estimates to G are S 8, A 7, B 5, C 4, D 2 and G 0 km.

  1. Expand S. The frontier has A with estimate 7, B with 5 and D with 2.
  2. Remove D because 2 is smallest. Expanding D generates G with estimate 0. The path cost to G is 9+2=11 km.
  3. Remove G and return S–D–G.

Only S and D were expanded. The 9-km route S–B–C–G was available, but B's estimate of 5 looked worse than D's 2. Greedy search never included the 9 km already spent reaching D in its comparison.

Separate guidance from guarantees

Even a heuristic that never overestimates does not make greedy search cost-optimal. The example estimates are admissible, yet the returned route is too expensive. Greedy search uses only the remaining estimate, so it can pay too much before reaching a promising state.

Graph search is complete on a finite state space when it handles duplicates properly. Tree-like greedy search can loop on appealing repeated states, and an infinite space can keep offering misleading low estimates. Worst-case time and space are O(bm), although a useful estimate can make an actual run short.

A place can be close to a destination in a straight line but require a long detour around a river. Small heuristic values do not certify good total routes. Computing the heuristic also takes time: reducing expansions helps only if evaluating those estimates does not consume the savings.

Key Takeaways

  • A heuristic estimates remaining cost and depends on the state.
  • Greedy best-first search orders by h and ignores accumulated cost.
  • Even an admissible heuristic does not make greedy search cost-optimal.
  • Finite graph search handles duplicates; tree-like greedy search can loop.

A* evaluates the whole proposed journey: the cost already paid plus an estimate of what remains. Its priority is

f(n)=g(n)+h(n).

Use a priority queue, replace more expensive paths and test a goal when it is removed. At a goal, h=0, so its priority is its actual path cost.

Trace the cost-plus-estimate rule

The two-way roads are S–A 2, S–B 3, S–D 9, A–C 4, B–C 1, B–D 6, C–G 5 and D–G 2 km. Heuristic estimates to G are S 8, A 7, B 5, C 4, D 2 and G 0. Break ties alphabetically.

Removed nodeWhat changes
S, f=8Add B with 3+5=8, A with 2+7=9 and D with 9+2=11
B, f=8Add C with 4+4=8; D via B is no cheaper
C, f=8Add G with 9+0=9
A, f=9C via A costs 6, worse than its stored 4
G, f=9Return S–B–C–G, cost 9 km

A is removed before G because of the tie rule. A* expands four non-goal nodes and never expands D. UCS on the same map expands D too. Setting every heuristic estimate to zero would remove this guidance and reproduce UCS.

Explain why an optimistic estimate works

An admissible heuristic never exceeds the true remaining cost h∗(n). For A* with reopening, admissibility guarantees cost optimality; tree-like A* has the same guarantee under the positive-cost search conditions.

Suppose a worse goal of cost C>C∗ were about to be removed. Some node on an optimal path must still be pending. For its optimal-path prefix,

f(n)=g(n)+h(n)≤g(n)+h∗(n)=C∗<C.

The queue must choose that node before the worse goal. This contradicts the proposed stopping point. Reopening matters because a cheaper prefix discovered later must be allowed to continue through a state already expanded.

A consistent heuristic makes f nondecreasing along paths. It ensures that the first expansion of a state uses a cheapest path to it. A* can then permanently close expanded states. With admissibility alone, a permanent closed set can discard an essential improvement.

Understand pruning and its limits

With consistency, A* expands every relevant node whose f<C∗, may expand nodes tied at C∗ and expands none above that value before returning. D's priority 11 exceeds the solution cost 9, so it stays unexpanded. In the class of forward path-building algorithms using the same heuristic information, A* is optimally efficient apart from ties. This is a comparison of necessary expansions, not a claim that its code always runs fastest.

Overestimation can break the argument. Change B's estimate to 9 although its true remaining cost is 6. B now has priority 12. A*, following S, A, C and D, returns S–A–C–G at cost 11 while B still waits.

A* still has an exponential worst case and stores generated search information.

Key Takeaways

  • A* ranks paths by g+h and tests goals on removal.
  • Admissibility guarantees cost optimality for A* that reopens improved states.
  • Consistency permits permanent closure after a state’s first expansion.
  • Overestimation can delay the optimal route until after a worse goal is returned.
  • Ties at the optimal cost can affect expansion counts.
  • A* with zero heuristic is UCS; ordinary A* can require substantial memory.

3.3 Trade optimality for speed or memory

When the frontier no longer fits or an answer arrives too slowly, choose which resource or guarantee to trade. Speed-oriented variants change priorities or discard candidates. Memory-oriented variants regenerate paths they could not keep.

Put more weight on the estimate

Weighted A* uses f=g+Wh with W>1. It usually favors progress toward a goal more strongly. With an admissible heuristic and the best-path updates and reopening of the general procedure, its returned cost is at most WC∗. That bound permits a worse solution; it does not require one.

On the example road map, use estimates S 8, A 7, B 5, C 4, D 2 and G 0, and weight 2. From S, the priorities are B 13, D 13 and A 16. Alphabetical ties select B. Its child C has 4+2(4)=12; C then generates G with priority 9. The cost-9 route is returned after three non-goal expansions. The guarantee allows up to 18 km, although this run finds the optimum.

In the same formula, weight 0 gives UCS and weight 1 gives A*. As the weight grows large, the estimate increasingly dominates comparisons, approaching greedy behavior.

Beam search keeps only the best k pending nodes and discards the rest. The retained frontier is bounded, but a discarded candidate can contain the only solution. It therefore gives neither completeness nor an optimality guarantee.

Deepen by an estimated-cost threshold

IDA* performs depth-first search with a cutoff on f=g+h. The first cutoff is the root's value. Prune any node above it, recording the smallest exceeded value. That value becomes the next cutoff; it is not necessarily the old cutoff plus 1. Use path cycle checks.

For the example map, the first cutoff is 8. A at 9 and D at 11 are pruned; B and C at 8 are explored, but G at 9 is pruned. The next cutoff is 9. In that iteration, the path through A produces C at 10 and is pruned. The path S–B–C–G stays within 9 and succeeds.

With admissibility, IDA* preserves cost optimality and needs only depth-first path storage. Its repeated passes can be expensive when costs produce many distinct thresholds. Small integer costs often make the number of thresholds more manageable.

Use bounded memory more selectively

Recursive best-first search (RBFS) stores the best alternative priority at each level. It follows the most promising branch until that alternative becomes better, then backs up. It uses linear memory but can regenerate forgotten branches.

SMA* uses the available memory, drops the worst frontier leaf when full and backs its value into its parent. This record allows later regeneration. With an admissible heuristic it is cost-optimal if an optimal solution path fits in memory. Otherwise it may return a worse solution, or fail if no solution path fits.

Choose A* for an optimal answer when storage suffices. Choose IDA* or a suitable memory-bounded variant when optimality matters but the frontier does not fit. Weighted A* offers a numerical quality bound; beam search offers aggressive pruning without that bound.

Key Takeaways

  • Weighted A* uses g+Wh and can return a solution costing up to WC∗ under its admissible-heuristic guarantee.
  • Beam search discards candidates and can lose the only solution.
  • IDA* raises its cutoff to the smallest exceeded f value.
  • RBFS and SMA* can regenerate forgotten work to limit memory.
  • SMA* needs enough memory for an optimal solution path to guarantee optimality.
4

Design and evaluate heuristics

A useful heuristic must fit both the problem and the guarantee you need. Admissibility compares its estimate with the true remaining cost; consistency compares neighboring estimates across each action. Relaxing restrictions gives a practical way to prove these properties without solving the original problem. Dominance and effective branching factor then help compare guidance, while timing reveals the cost of computing it.

4.1 Test heuristics for admissibility and consistency

A heuristic can be optimistic overall yet change too sharply between neighboring states. Admissibility and consistency capture these different checks, and each supports a different version of A*.

Compare estimates with true costs

An admissible heuristic satisfies 0≤h(n)≤h∗(n) at every state. At a goal, the true remaining cost is zero, so its estimate must also be zero. Admissible does not mean accurate: zero everywhere is safe but provides no direction.

On the example road map, the estimates and exact cheapest remaining distances to G are:

StateEstimateTrue remaining cost
S89
A79
B56
C45
D22
G00

Every estimate is at most its true cost. In a large problem, computing these exact costs may be as hard as the original search. A proof from the problem's structure is then more useful than an exhaustive table.

Check every action

Consistency, also called monotonicity, requires h(n)≤c(n,a,n′)+h(n′) for every action, plus zero at goals. The current estimate cannot exceed one step's cost plus the successor estimate.

On the road map, A→C gives 7≤4+4, C→B gives 4≤1+5 and D→G gives 2≤2+0. Two-way roads require both directions. All 16 directed checks hold for these estimates.

Adding the inequalities down a path to a goal cancels the intermediate estimates. It gives h(n)≤h∗(n) on an optimal path, so consistency implies admissibility. It also gives

f(n′)=g(n)+c(n,a,n′)+h(n′)≥g(n)+h(n)=f(n).

Priorities cannot fall along a path. The first expansion of a state is therefore on a cheapest path, even if its first generation was more expensive.

See why admissibility alone needs reopening

Consider two-way roads S–A 1, A–C 1, S–B 1, B–C 2 and C–G 3. Let the estimates be S 0, A 4, B 1, C 1 and G 0. They do not exceed the true costs S 5, A 4, B 5, C 3 and G 0, so they are admissible. But A→C violates consistency: 4>1+1.

A* expands S, then B with priority 2, then C reached for cost 3 with priority 4. It then expands A with priority 5 and discovers a cheaper path to C of cost 2. Permanently rejecting C because it is closed leaves a cost-6 goal. Reopening C propagates the improvement and produces the optimum, cost 5.

Match the movement model

Manhattan distance is admissible and consistent for horizontal and vertical unit moves. If diagonal moves also cost 1, traveling from (0,0) to (3,3) takes only three moves, while Manhattan distance says 6. For that movement model, max⁡(∣Δx∣,∣Δy∣) gives the obstacle-free distance. A heuristic's guarantee belongs to a particular action model.

Key Takeaways

  • Admissibility bounds an estimate by true remaining cost.
  • Consistency checks each directed action and requires zero at goals.
  • Consistency implies admissibility; admissibility does not imply consistency.
  • Consistent heuristics make f nondecreasing along a path.
  • Admissible but inconsistent heuristics require reopening for the general A* guarantee.
  • Changing the allowed moves can invalidate a heuristic.

4.2 Invent admissible heuristics from relaxed problems

To design a safe estimate, solve an easier version of the problem. A relaxed problem removes action restrictions, so every original solution remains available. Its cheapest cost cannot exceed the original cheapest cost.

Remove restrictions deliberately

An exact relaxed cost is an admissible heuristic. It is also consistent when original actions remain available with their costs: taking an original step and then an optimal relaxed route is one possible relaxed route, so the relaxed optimum cannot cost more.

In the 8-puzzle, a tile can move to an adjacent square only when that square is blank. Remove the blank requirement and tiles may pass through occupied squares. Each numbered tile then needs at least its horizontal plus vertical distance to its target. Summing gives Manhattan distance, h2.

Remove adjacency as well and each misplaced tile can jump straight to its target in one move. The resulting cost is the misplaced-tile count, h1. Both are easy to calculate without searching the original puzzle.

Work out both estimates

For goal "1 2 3 / 4 5 6 / 7 8 blank", consider "5 1 3 / 4 blank 2 / 7 8 6". Number rows and columns from 1.

TileCurrent positionGoal positionDistance
5(1,1)(2,2)2
1(1,2)(1,1)1
2(2,3)(1,2)2
6(3,3)(2,3)1

The other numbered tiles are already correct. Four are misplaced, so h1=4. Their distances total 2+1+2+1=6, so h2=6. The optimal solution takes 12 moves; the relaxations ignore interactions that create extra work.

Do not count the blank. One move from the goal, a numbered tile and the blank are both displaced. Counting both would give 2 when the true cost is 1. The blank enables moves; it is not an additional tile to charge for.

Store solved subproblems

A pattern database records exact costs for a selected subproblem, such as placing tiles 1 through 4 correctly while treating other tiles as interchangeable. Build the table once by backward search from the goal. During a new search, use a lookup instead of solving the subproblem again.

The subproblem needs no more work than the full problem, giving a lower bound. However, adding two ordinary pattern costs can charge the same real move twice. Addition is safe for disjoint patterns when each database counts only moves of its own tiles. Disjoint tile names alone do not establish that cost accounting rule.

Combine safe estimates

The maximum of admissible estimates is admissible:

h(n)=max⁡{h1(n),…,hk(n)}.

Every candidate stays below the true remaining cost, so their maximum does too. It is at least as informative as each individual estimate. A plain sum lacks this protection.

A heuristic learned from solved examples may predict remaining cost well on average. Average accuracy does not establish a lower bound on every state. It retains A*'s admissible-heuristic guarantee only when its estimates are shown never to overestimate.

Key Takeaways

  • An exact relaxed-problem cost is a lower bound on the original cost.
  • Misplaced tiles and Manhattan distance come from different 8-puzzle relaxations.
  • Exclude the blank when computing either puzzle heuristic.
  • Pattern databases trade precomputation and table storage for fast lookups.
  • Add pattern costs only with cost accounting that avoids counting moves twice.
  • The maximum of admissible heuristics is admissible.
  • Learning a heuristic does not by itself prove admissibility.

4.3 Compare heuristics by dominance and effective branching factor

A closer estimate can reduce exploration, but a costly estimate can still make search slower. Compare both the information supplied and the total computation required.

Establish dominance over every state

An admissible heuristic h2 dominates admissible h1 if h2(n)≥h1(n) everywhere. One favorable board is not enough to prove this relationship.

Manhattan distance dominates misplaced-tile count in the 8-puzzle. Each misplaced tile must travel at least one square, so its Manhattan contribution is at least the 1 counted by the weaker heuristic. A correctly placed tile contributes zero to both.

With consistent estimates, A* must expand paths with g+h<C∗. Raising a safe estimate removes some paths from this mandatory region. A dominating consistent heuristic expands no more nodes apart from differences at ties. An inadmissible estimate can be larger still, but it loses the optimality guarantee and does not qualify for this dominance comparison.

Summarize search effort

The effective branching factor, b∗, describes the breadth of an equivalent uniform tree. Count N generated nodes below the root and let the solution depth be d. Solve

N+1=1+b∗+(b∗)2+⋯+(b∗)d.

The extra 1 accounts for the root. Consistent counting matters: if a measurement already includes the root, do not add it twice.

For 52 generated nodes below the root and solution depth 5, the total is 53 and b∗≈1.92. For 1,000 generated nodes and depth 8, b∗≈2.20. Find these values numerically by increasing or decreasing a trial value until its geometric sum matches the node total.

A value near 1 indicates a narrow search. Compare results across representative instances, with the same counting rule and comparable solution depths. Effective branching factor can help estimate scaling, but an unusually easy instance is not a reliable forecast for an entire problem family.

Time the whole computation

Suppose a node takes 10 microseconds, including 1 microsecond to evaluate the old heuristic. A replacement halves the node count but takes 100 microseconds per evaluation. Non-heuristic work still costs 9 microseconds, so the new per-node total is 109. The overall time ratio is

0.5×10910=5.45.

The search is about 5.5 times slower despite visiting fewer nodes. If the new evaluation takes only 2 microseconds, the node total becomes 11 and the time ratio is 0.5×11/10=0.55. That is about 1.8 times faster.

A pattern database also has a construction cost. Many searches with the same goal can share that investment; one small search may not repay it. Measure preprocessing, lookup time, generated nodes and memory separately so that fewer expansions are not mistaken for an automatic speed improvement.

Key Takeaways

  • Dominance requires two admissible heuristics and an inequality holding at every state.
  • A dominating consistent heuristic reduces necessary A* expansions, apart from ties.
  • Effective branching factor fits a uniform tree to node count and solution depth.
  • Count the root once when using the geometric-sum equation.
  • Total runtime includes heuristic evaluation and any precomputation.
5

Use local search for very large spaces

Some problems ask for a good arrangement, not a route to it. Local search works directly on complete candidates and stores very little search history. The challenge shifts from managing a frontier to moving through a landscape with local optima, flat regions and ridges. Hill climbing, restarts, simulated annealing and population methods differ in how they keep making progress when an immediate improvement is unavailable.

5.1 Describe local search and the state-space landscape

Local search repeatedly changes a complete candidate answer. It suits tasks where the final configuration matters and the sequence used to find it can be discarded.

Represent a full candidate

For 8-queens, place one queen in each column. Represent the state by the eight row numbers, reading columns from left to right. Every state has all eight queens, including states with conflicts. A neighbor moves one queen to another row in its own column.

There are 88=16,777,216 states and 8×7=56 neighbors per state. A fixed number of current states replaces the large frontier and parent records of path search. Storage still depends on the size of a state; retaining one eight-entry tuple is smaller than retaining one huge timetable.

Timetabling, chip layout and choosing a complete tour through cities have the same broad pattern: each state is a full proposal. A tour is itself a candidate arrangement, even though its content describes travel. Local search need not preserve the sequence of edits used to improve that tour.

Define what better means

An objective function gives each state a score to maximize. Equivalently, define a cost to minimize. For n-queens, let h count pairs of queens attacking each other. Count each pair once, including attacks along rows or diagonals even when another queen lies between them. A solution has h=0.

For four columns, the tuple (1,2,3,4) puts all queens on one diagonal. Its (42)=6 pairs all attack. The tuple (2,1,3,4) has two attacking pairs, while (2,4,1,3) has none. Here lower values are better; the letter h is an objective cost, not a remaining path-cost estimate used by A*.

Read the landscape

Imagine state quality as height. For maximization:

  • A global maximum has the best value anywhere in the space.
  • A local maximum is better than its neighbors but can be worse than a distant state.
  • A plateau is a connected flat region. It may be a flat local maximum with no uphill exit, or a shoulder from which sideways moves can reach an uphill exit.
  • A ridge can rise in a direction that the available single moves cannot follow. Every immediate choice may look worse.

For cost minimization, reverse height: search seeks minima and valleys. A local minimum is not proof that no lower-cost state exists elsewhere. The neighborhood determines which states can be compared in one step, so changing the allowed edit can change where search gets stuck.

Check that the path can be ignored

A route-finding agent must return legal actions from its actual start. A good destination alone is insufficient. Local search generally returns only the candidate state, without a parent chain back through all earlier edits.

A complete local-search method would find a goal whenever one exists; an optimal one would find the global best. Basic local methods give neither general guarantee. Their appeal is that they can reach good candidates quickly when storing a systematic search tree is impractical.

Key Takeaways

  • Local search edits complete candidate states and usually discards the path of edits.
  • An objective function defines which neighboring states are better.
  • A local optimum can be worse than a distant global optimum.
  • A shoulder has an uphill exit reachable through equal-value moves.
  • The neighborhood affects both the search landscape and where progress stops.

5.2 Climb toward better states with hill climbing

Hill climbing makes the best immediate improvement it can find. For a score to maximize, steepest ascent chooses the highest-scoring neighbor. For a cost to minimize, it chooses the lowest-cost neighbor. It stops when no strict improvement exists.

Follow a four-queen run

Let a state list the queen's row in each column and let h count attacking pairs. Begin with (1,2,3,4), whose cost is 6.

  1. Evaluate the one-queen moves. A best neighbor is (2,2,3,4), with cost 4.
  2. From there, a best neighbor is (2,1,3,4), with cost 2.
  3. No one-queen neighbor has cost below 2. Strict hill climbing stops.

The cost-zero arrangement (2,4,1,3) exists, but it cannot be reached by an immediately improving move from the stopped state. This is a consequence of the local rule, not evidence that the program miscounted conflicts.

Allow useful sideways movement

A sideways move keeps the same score. It can cross a shoulder to an improving exit, but it can also wander on a flat local optimum. Limit consecutive sideways moves to avoid endless cycling.

In Russell and Norvig's reported 8-queens experiment, steepest ascent from random starts succeeds about 14% of the time, taking about 4 steps on success and 3 when stuck. Allowing up to 100 consecutive sideways moves raises reported success to about 94%, with about 21 steps per success and 64 per failure. These are results for that experiment, not universal success rates for hill climbing.

Change how a neighbor is chosen

Stochastic hill climbing randomly selects an improving neighbor, possibly favoring larger improvements. First-choice hill climbing samples neighbors one at a time and takes the first improvement. It avoids evaluating an enormous neighborhood before every move. Both still refuse worse moves.

Random-restart hill climbing begins a fresh run from a newly sampled state after a failed run. With independent runs of success probability p, the expected number of runs through the first success is 1/p. For p=0.14, that is about 7 runs. Using the reported step counts, expected total steps are

4+0.860.14×3≈22.

The failed runs contribute work too. With positive success probability and independent restarts, the probability of eventually succeeding approaches 1 as the number of runs grows.

Let several candidates share discoveries

Local beam search keeps k states, generates their neighbors together and retains the best k from that pooled set. A promising parent may contribute several survivors while another contributes none. This sharing distinguishes it from independent restarts.

Pooling can also make all candidates cluster in one region. Stochastic beam search samples survivors with probability increasing with quality to preserve more variety. The choice between sideways moves, restarts and population diversity depends on why progress is failing: a nearby equal-value bridge, a bad starting region or too many candidates exploring the same area.

Key Takeaways

  • Steepest-ascent hill climbing accepts the best strict improvement and otherwise stops.
  • Sideways moves can cross shoulders but need a limit on flat regions.
  • First-choice hill climbing samples until it finds an improvement.
  • Independent restarts with success probability p take 1/p runs on average.
  • Local beam search selects from pooled neighbors, so candidates share progress.
  • Population clustering can reduce exploration even when several states are retained.

5.3 Escape local optima with simulated annealing and genetic algorithms

Some landscapes require a temporary loss before a better state becomes reachable. Simulated annealing allows such moves with a controlled probability. Genetic algorithms instead explore by selecting and combining complete candidates.

Accept a worse move sometimes

Simulated annealing samples one random neighbor. Accept an improving move. For a maximized objective, write its change as ΔE. If ΔE<0, accept the worse move with probability

P=eΔE/T,T>0.

For cost minimization, let Δ be the increase in cost. A worse move then has Δ>0 and acceptance probability e−Δ/T. Equal-value moves have probability 1 under either formula. Temperature and objective changes must use a compatible numerical scale.

A score drop of 2 is accepted with probability about 0.819 at temperature 10, 0.135 at temperature 1 and 0.018 at temperature 0.5. At temperature 10, a larger drop of 5 has probability about 0.607. Thus temperature controls tolerance, while the size of the loss still matters at the same temperature.

Lower the temperature

A cooling schedule sets temperature over time. Geometric cooling uses Tk+1=αTk with a factor close to 1, such as 0.95. At high temperature, many worse moves are accepted and exploration resembles a random walk. Near zero, worse moves become rare and behavior resembles hill climbing.

Cooling too fast can trap the search before it escapes a poor region. Cooling very slowly increases computation. The asymptotic global-optimum result needs sufficiently slow cooling and the usual ability to reach states through the neighborhood; an ordinary finite geometric run is not a certainty of global success. Used for chip layout and scheduling since the 1980s, the method takes its name from heating and slowly cooling metal so that it settles into a lower-energy structure.

Build a new population

A genetic algorithm represents candidates as strings. Each generation scores their fitness, selects parents with preference for higher fitness, creates children by crossover and applies occasional mutations.

For 8-queens, eight row digits describe one queen per column. Fitness can count non-attacking pairs, with 28 as the maximum. Cut parent strings "64751517" and "64278273" after the fourth digit. Combining opposite halves gives "64758273" and "64271517".

The parents have fitness 23 and 24; the children have fitness 27 and 21. One child improves on both parents while the other is worse. Crossover offers new combinations, not a guarantee of improvement. It is useful when good blocks tend to retain value when combined. Mutation occasionally changes a position and helps introduce variety beyond those combinations.

Selection, crossover and mutation play different roles: selection favors useful candidates, crossover recombines them and mutation changes individual positions. Like stochastic beam search, the method maintains a population, but new candidates can draw material from two parents. Neither a high-fitness parent nor a low final temperature alone proves that the global optimum has been found.

Key Takeaways

  • Annealing samples a neighbor and accepts worse moves with a temperature-dependent probability.
  • For a cost increase Δ>0, acceptance probability is e−Δ/T.
  • Cooling reduces exploration; cooling too quickly can leave a local optimum.
  • Genetic algorithms combine fitness-based selection, crossover and mutation.
  • Crossover can produce both better and worse children.

Uninformed and Informed Search examples

5 Walkthroughs

1

Turn a problem into a search

13 steps
Formulate a puzzle, distinguish states from paths and measure the size of a search.
  1. 1
    IntroductionFrom choices to a solution

    A search algorithm does not receive an instruction such as "solve this somehow." It receives a model of possible situations (states) and legal actions.

    Use a sliding puzzle to build that model, then follow the search records it produces, called nodes. The model describes the world; the records describe the paths being considered. That distinction will explain why two nodes can end in one state and why storing every possible path can become expensive.

  2. 2
    ExampleSpecify the puzzle

    For the 8-puzzle, a state lists the positions of eight numbered tiles and the blank. The initial state is the supplied board.

    The goal layout is "1 2 3 / 4 5 6 / 7 8 blank". Legal actions move the blank left, right, up or down without leaving the board. The transition swaps it with a neighboring tile. Each action costs 1. These choices specify the problem before any search begins.

  3. 3
    ExplanationReturn actions, not just a destination

    The goal test recognizes a successful board. A path solution still needs the legal moves that reach it from the initial board.

    If each move costs 1, a path of six moves costs 6. With unequal road costs, add the edge costs instead of counting actions. A goal state tells you where you want to end; the solution tells you how to get there, and the path cost tells you what that journey costs.

  4. 4
    ChallengeKeep the detail that changes actions

    A route planner models a robot by its current room. Some doors require a key that the robot may carry. Can the planner safely omit whether the robot has the key?

    ---reveal---

    No. Key possession changes the legal actions from the same room. The state must record it, or an abstract route may include a door crossing the robot cannot perform. The robot’s paint color can be omitted if it changes neither actions nor costs.

  5. 5
    Key InsightGenerate a large space as needed

    An implicit space is a recipe for successors, not a stored list of every state. This matters even for small-looking puzzles: the 8-puzzle has 181,440 reachable states, while the 15-puzzle has about 1.05×1013.

    Search generates the portion it needs. Choosing a better representation can reduce that portion too: placing each queen only in the next empty column removes many redundant placement orders.

  6. 6
    ExplanationStore a path in each node

    A state is a situation. A node is a path record containing that state, its parent, the incoming action and accumulated cost g.

    Routes "S, A, C" and "S, B, C" produce different nodes ending at C. The map contains one C, but the search tree can contain both arrivals. Following parent links from a returned goal and reversing the actions recovers its particular route.

  7. 7
    ExampleSeparate pending and reached records

    On the two-way map, S has roads to A for 2 km, B for 3 km and D for 9 km. Expanding S generates three nodes with parent S.

    The frontier now holds A, B and D, waiting for selection. The reached table contains S as well as those three states. It remembers generated states, not only expanded ones, so another route cannot silently add an unnecessary duplicate of a pending state.

  8. 8
    ExplanationPropagate an improvement

    Suppose C is first reached through A at cost 6. Later, B offers a route to C costing 4. Replace C’s best record, including its parent, so later routes inherit the cheaper prefix.

    If C has already been expanded, some algorithms must reopen it to pass the improvement onward. If a heap still contains the old cost-6 entry, skip that stale entry when it is removed; it no longer represents C’s best path.

  9. 9
    ChallengeRecover the correct route

    A goal node Z has parent M. M’s best node has parent K, and K’s parent is the root R. An older node for M had parent P. What route should be returned?

    ---reveal---

    Return R–K–M–Z by following the returned node’s actual parent chain backward, then reversing it. The older M node describes a different path. Mixing its parent with the improved cost would make the reported route disagree with its own search record.

  10. 10
    ExplanationAsk four separate questions

    Complete means finding a solution whenever one exists. Cost-optimal means returning the cheapest solution. An unsolvable infinite space need not produce a terminating failure report.

    Time measures generated or expanded nodes; space measures peak retained information. A method can be complete yet return an expensive route, or return the cheapest route while using too much memory to be practical on a larger instance.

  11. 11
    ExampleWatch the layers grow

    For branching factor 10, the layers through depth 5 contain 1, 10, 100, 1,000, 10,000 and 100,000 nodes. Together they contain 111,111 nodes.

    Most are in the last layer. This is why an extra depth level matters so much: it adds another 1,000,000 paths before duplicate checks. At 1 kilobyte per node, broad exploration can reach a storage limit even when node generation itself is fast.

  12. 12
    ChallengeDo not confuse a short path with a cheap one

    A complete algorithm always returns a two-action route costing 17 units, although a four-action route costs 10. Is it cost-optimal, and does its completeness claim settle that question?

    ---reveal---

    It is not cost-optimal because a cheaper solution exists. Completeness establishes that it finds a solution, not which solution it chooses. The extra actions do not make the four-action route worse when the objective is total cost.

  13. 13
    RecapRead a search trace with purpose

    Keep three layers distinct: the problem’s states and actions, the paths stored as nodes, and the rule selecting the next frontier node. Then ask whether the returned path meets the desired objective.

    For resource comparisons, identify branching factor, solution depth and maximum depth. Check what is stored as well as what is expanded; two strategies can seek the same goal with very different memory requirements.

2

Trace uninformed search on one map

16 steps
Compare queue, cost and stack ordering, then choose a strategy under memory and reversibility limits.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionOne map, several search orders
  2. 2
    ExampleStart the breadth-first queue
  3. 3
    ExampleLet the first goal appear
  4. 4
    ChallengeInterpret the BFS result
  5. 5
    TipUse the matching BFS bound
  6. 6
    ExampleOrder by cost already paid
  7. 7
    ExampleRemove the goal at minimum cost
  8. 8
    ChallengeWait for the cheaper unfinished route
  9. 9
    Key InsightBound the cost of endless depth
  10. 10
    ExampleFollow the depth-first branch
  11. 11
    ExplanationDistinguish a boundary from failure
  12. 12
    ExamplePay a small price for less memory
  13. 13
    ChallengeChoose a depth strategy
  14. 14
    ExplanationMeet a search from the goal
  15. 15
    ChallengeSelect by costs and reverse access
  16. 16
    RecapMatch the guarantee to the task
3

Guide a search with estimates

15 steps
Trace greedy search and A*, then inspect the speed and memory trades of common variants.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionEstimate the unfinished journey
  2. 2
    ExplanationGive the estimate a meaning
  3. 3
    ExampleLet apparent closeness choose
  4. 4
    ChallengeChoose between a cheap prefix and a small estimate
  5. 5
    ExampleAdd the two costs
  6. 6
    ExampleResolve the final tie
  7. 7
    Key InsightKeep an optimal route competitive
  8. 8
    ExplanationKnow when a closed state stays closed
  9. 9
    ChallengeDiagnose a missing improvement
  10. 10
    ExampleEmphasize progress toward the goal
  11. 11
    ExplanationRaise a cost contour instead of keeping a frontier
  12. 12
    ExampleMove the cutoff from eight to nine
  13. 13
    TipDecide whether forgotten paths can return
  14. 14
    ChallengeChoose a guarantee under limited memory
  15. 15
    RecapSeparate ordering, stopping and memory
4

Build and check a safe heuristic

15 steps
Test state and edge bounds, derive puzzle estimates and compare their computational value.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionProve the estimate is safe
  2. 2
    ExplanationCheck the true-cost bound
  3. 3
    ExampleCheck a directed step
  4. 4
    ChallengeSeparate an optimistic estimate from a smooth one
  5. 5
    ConnectionLet the moves determine the distance
  6. 6
    ExplanationMake an easier problem deliberately
  7. 7
    ExampleRelax two puzzle restrictions
  8. 8
    ExampleCount the displaced numbered tiles
  9. 9
    ChallengeAvoid counting one move twice
  10. 10
    ExplanationPrecompute and combine lower bounds
  11. 11
    ExplanationCompare estimates everywhere
  12. 12
    ExampleFit an equivalent tree
  13. 13
    ExampleCharge for heuristic computation
  14. 14
    ChallengeUse two estimates without a dominance claim
  15. 15
    RecapJudge safety and usefulness separately
5

Improve complete candidates

16 steps
Follow queen-placement hill climbing, then use restarts, annealing and crossover to explore beyond immediate improvement.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSearch for an arrangement
  2. 2
    ExamplePut every queen into the state
  3. 3
    ExampleCount attacking pairs
  4. 4
    ExplanationPicture the traps
  5. 5
    ChallengeDecide whether the edit history matters
  6. 6
    ExampleFollow the best immediate moves
  7. 7
    ExplanationTry sideways motion or a fresh start
  8. 8
    ChallengeInclude the successful run
  9. 9
    ConnectionShare progress without losing every alternative
  10. 10
    ExplanationAccept a temporary loss
  11. 11
    ExampleHold the loss fixed and lower temperature
  12. 12
    ChallengeKeep the signs consistent
  13. 13
    TipCool at a useful pace
  14. 14
    ExampleCombine two parent strings
  15. 15
    ChallengeDiagnose a stagnant population
  16. 16
    RecapChoose a way past the obstacle

Uninformed and Informed Search practice questions

50 Practice Questions in 5 sets

Set 1: States, frontiers and uninformed search10 Practice Questions

Question 1 of 10

A route planner returns only the name of the destination. What must it return to supply a path solution?
  1. The estimate of the distance remaining at the destination.
  2. The actions leading from the start to the destination.
  3. The list of every place the planner generated during search.
  4. The action with the lowest cost anywhere on the map.
Show answerHide answer
Answer: B
A path solution is a sequence of legal actions from the initial state to a goal. The destination names a successful final state but leaves the route unspecified. Listing all generated places also fails: many of those places can belong to abandoned branches rather than to one connected route.

Question 2 of 10

A node has been generated and placed in the frontier, but has not been expanded. Where is its state recorded in graph search?
  1. Only in the closed set, before expansion.
  2. In the reached table only after expansion.
  3. Only in its parent, until it is expanded.
  4. In the reached table, even before expansion.
Show answerHide answer
Answer: D
The reached table records states when they are generated, so it includes frontier states as well as expanded states. Waiting until expansion allows several parents to queue the same state. A closed set usually records expanded states, which is a narrower role than the reached table.

Question 3 of 10

A full search tree has branching factor 3 and extends through depth 4. How many nodes does it contain, including the root?
  1. 121 nodes
  2. 81 nodes
  3. 120 nodes
  4. 364 nodes
Show answerHide answer
Answer: A
Count every layer: the root contributes 1, then the layers contribute 3, 9, 27 and 81. Their sum is 121. The value 81 counts only the deepest layer, while 120 counts all generated nodes below the root but omits the root requested in the question.

Question 4 of 10

Directed edges are R→K, R→M, K→N, M→Z and N→Z. BFS starts at R and seeks Z, generating neighbors alphabetically. What path does it return?
  1. R–K–N–Z
  2. R–K–M–Z
  3. R–M–Z
  4. R–M–N–Z
Show answerHide answer
Answer: C
After expanding R, the queue contains K and M. Expanding K appends N behind M; expanding M then generates Z and the early goal test returns R–M–Z. Following K immediately through N would be depth-first behavior and would miss the shallower two-edge solution.

Question 5 of 10

A directed map has P→Q 5 km, P→R 2 km, R→Q 1 km and Q→Z 4 km. What route and cost does UCS return from P to Z?
  1. P–Q–Z, 9 km
  2. P–R–Q–Z, 6 km
  3. P–Q–Z, 7 km
  4. P–R–Q–Z, 7 km
Show answerHide answer
Answer: D
UCS first expands R at cost 2 and improves Q from cost 5 to cost 3. Q then generates Z at cost 7, giving P–R–Q–Z. Keeping Q's first arrival would return the cost-9 route; graph search must replace a more expensive pending path when it discovers a cheaper one.

Question 6 of 10

Depth-limited search ends with a cutoff at limit 6. What does that result establish?
  1. The limit prevented the search from being exhausted.
  2. The reachable state space contains no goal at any depth.
  3. The shallowest goal must be exactly seven actions away.
  4. The reachable state space has maximum depth six.
Show answerHide answer
Answer: A
A cutoff reports that the depth boundary blocked further exploration. It leaves open the possibility of a deeper solution and also the possibility that no solution exists. It does not locate a goal at the next depth; only further search could establish where a goal is reachable.

Question 7 of 10

A finite-branching puzzle has equal move costs, unknown goal depth and too little memory for a broad frontier. What uninformed method finds a shallowest solution with depth-first storage?
  1. Uniform-cost search
  2. Iterative deepening search
  3. Greedy best-first search
  4. Depth-first search
Show answerHide answer
Answer: B
Iterative deepening tries increasing depth limits, so the first successful iteration reaches a shallowest solution while using depth-first storage. Ordinary DFS can stop at a deeper solution and lacks that guarantee. UCS preserves cheapest cost but retains a potentially broad priority frontier, which conflicts with the memory limit.

Question 8 of 10

A system can enumerate successors but cannot enumerate predecessors. It has one explicit goal. What prevents the usual bidirectional search?
  1. The forward search cannot recognize the goal state.
  2. The two directions must have different edge costs.
  3. The backward search cannot generate its next states.
  4. The goal must describe several acceptable states.
Show answerHide answer
Answer: C
The backward half needs predecessors: states that can lead into its current state. Knowing the goal supplies its starting point but does not supply those reverse transitions. An explicit goal alone is therefore insufficient; ordinary forward successor generation does not necessarily provide a usable backward search.

Question 9 of 10

A search can choose from finitely many actions at every state. One branch is infinite, and another reaches a goal in four actions. What can be concluded about BFS and tree-like DFS with path cycle checks?
  1. BFS finds a goal; DFS can stay on the infinite branch.
  2. Both find a goal because each state has finitely many actions.
  3. DFS finds a goal; BFS may stay within a shallow infinite layer.
  4. Neither finds a goal because the state space is infinite.
Show answerHide answer
Answer: A
Finite branching makes each BFS layer finite, so it eventually reaches depth four. DFS can keep extending the infinite branch through distinct states without triggering a path cycle check. Cycle checking removes repeated ancestors, but an infinite chain of new states remains an obstacle to DFS completeness.

Question 10 of 10

UCS searches a finite-branching infinite graph. Every step costs more than zero, but there is no positive lower bound on step cost. An infinite chain has accumulated costs approaching 2, while a direct goal costs 3. What can happen?
  1. UCS must return the goal because every step has positive cost.
  2. UCS can expand the chain forever before removing the goal.
  3. UCS must report failure after the chain cost reaches 2.
  4. UCS returns a cheaper goal somewhere along the chain.
Show answerHide answer
Answer: B
Every finite prefix of the chain costs less than 2 and therefore outranks the cost-3 goal. UCS can keep finding another cheaper frontier node forever. Strictly positive individual costs are insufficient for this infinite-space completeness argument; a uniform positive lower bound would prevent infinitely many steps below a fixed cost.
Set 2: Heuristics, A* and memory limits10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An IDA* iteration uses cutoff 14. The values pruned above the cutoff are 17, 19, 17 and 24. What cutoff is used next?
  1. 17
  2. 15
  3. 19
  4. 24
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Greedy best-first search has frontier nodes L with accumulated cost 2 and estimate 8, M with cost 9 and estimate 1, and N with cost 4 and estimate 3. What does it remove next?
  1. L
  2. N
  3. M
  4. L and N together
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A* has frontier nodes J with accumulated cost 4 and estimate 6, K with cost 7 and estimate 2, and L with cost 2 and estimate 8. What node has the lowest priority value?
  1. K
  2. J
  3. L
  4. J and L together
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A greedy search uses an admissible heuristic and returns a cost-18 route, although a cost-13 route exists. Why is this outcome compatible with its rule?
  1. An admissible estimate must equal the remaining cost at every state.
  2. It orders by accumulated costs without using remaining estimates.
  3. An admissible estimate permits every goal to have a positive estimate.
  4. It orders by remaining estimates without charging the path already taken.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A directed map has R→T 3, R→U 6, T→Z 9 and U→Z 2. Estimates are R 5, T 4, U 2 and Z 0. What goal cost does A* return?
  1. 12
  2. 8
  3. 7
  4. 11
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Weighted A* uses an admissible heuristic, reopening and weight 1.5. The optimal cost is 20. What upper bound does its guarantee place on the returned cost?
  1. 20
  2. 30
  3. 21.5
  4. 40
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A* has a goal of cost 16 on its frontier and a non-goal node of priority 14. What must it do next if all other priorities are larger?
  1. Return the goal node that is already generated.
  2. Remove the goal and declare its path optimal.
  3. Discard the non-goal node with the lower priority.
  4. Remove the non-goal node and continue searching.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A finite search needs an optimal path. Its heuristic is admissible, costs have only a few integer values and ordinary A* exhausts frontier memory. Memory easily holds a solution path. What method preserves optimality using depth-first passes?
  1. Beam search
  2. Weighted A* with weight 2
  3. IDA*
  4. Greedy best-first search
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A directed map has S→A 2, S→B 1, B→A 2 and A→G 4. Estimates are S 0, A 0, B 7 and G 0. A* tests goals on removal. What cost does it return, and what heuristic defect explains the result?
  1. 6; B overestimates, but the returned route is still optimal.
  2. 7; B overestimates and hides the cheaper route through A.
  3. 6; all estimates are admissible, so optimality is guaranteed.
  4. 7; A is inconsistent because its estimate is zero.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

SMA* has an admissible heuristic. Its memory can hold a complete solution path of cost 25, but every optimal path of cost 19 needs more memory than is available. What guarantee remains about its returned cost?
  1. It must still return the optimal cost of 19.
  2. It must report failure and return no path.
  3. It must return a cost of at most 1.5 times 19.
  4. It may return 25; cost 19 is not guaranteed.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Check, construct and compare heuristics10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

At a state whose true cheapest remaining cost is 11, a heuristic gives 13. What property is violated at this state?
  1. Completeness
  2. Cost positivity
  3. Finite depth
  4. Admissibility
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Two admissible estimates at a state are 7 and 10. What value does their maximum combination use?
  1. 7
  2. 17
  3. 10
  4. 3
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A directed edge X→Y costs 3. The estimates are 8 at X and 4 at Y. What does this edge establish about consistency?
  1. It fails because 8 exceeds 3 + 4.
  2. It holds because both are positive.
  3. It holds because estimates drop by 4.
  4. It fails because 4 is below 3 + 8.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

The 8-puzzle goal is "1 2 3 / 4 5 6 / 7 8 blank". For "1 2 3 / 4 5 6 / blank 7 8", what are the misplaced-tile and summed Manhattan estimates?
  1. 3 and 4
  2. 2 and 2
  3. 2 and 4
  4. 3 and 2
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A search generates 30 nodes below its root and finds a solution at depth 4. What effective branching factor exactly fits this node count?
  1. 2
  2. 3
  3. 4
  4. 1.5
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A designer removes an action restriction but leaves every original action available at its original cost. Why is the exact relaxed cost a safe lower bound?
  1. Every relaxed solution must remain legal in the original problem.
  2. Every relaxed solution must use fewer actions than any original solution.
  3. Every original solution remains available in the relaxed problem.
  4. Every original action must now have a strictly lower numerical cost.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A directed map has R→X 2, R→Y 1, Y→X 2 and X→Z 5. Estimates are R 0, X 0, Y 6 and Z 0. Is the heuristic admissible and consistent?
  1. Consistent, but inadmissible.
  2. Both admissible and consistent.
  3. Neither admissible nor consistent.
  4. Admissible, but inconsistent.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Two pattern databases use disjoint tile sets, but each table charges one unit for every puzzle move, including moves of other tiles. A single move can advance both subproblems. What combination is guaranteed admissible?
  1. The sum, because the tile sets are disjoint.
  2. The maximum of the two table values.
  3. Twice the larger of the two table values.
  4. The sum minus one, for every puzzle state.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

An old search evaluates 80,000 nodes at 12 microseconds each, including 2 for its heuristic. A new heuristic takes 8 microseconds and reduces nodes to 48,000; other per-node work is unchanged. What is the new total time relative to the old?
  1. 60% of the old time
  2. 120% of the old time
  3. 90% of the old time
  4. 150% of the old time
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Admissible heuristics H and J give values 4 and 7 at state X, and 9 and 6 at state Y. What can be concluded about dominance and their maximum?
  1. Neither dominates; their maximum is admissible.
  2. J dominates H; their maximum is admissible.
  3. H dominates J; their maximum can overestimate.
  4. Neither dominates; their sum is always admissible.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Landscapes, restarts and population search10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A timetable optimizer returns a full schedule and discards the sequence of swaps used to find it. What makes local search suitable for this task?
  1. The final arrangement is the required answer.
  2. The swaps must form the cheapest possible path.
  3. Every candidate schedule must have equal quality.
  4. The full set of schedules must fit into memory.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A 6-queens local-search state has one queen per column. One move changes a queen to a different row in its column. How many neighbors does each state have?
  1. 36
  2. 25
  3. 30
  4. 12
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A cost-minimizing strict hill climber is at cost 7. Neighbor costs are 9, 7, 8 and 10. What does it do?
  1. Move sideways.
  2. Move to cost 8.
  3. Restart randomly.
  4. Stop at cost 7.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Independent hill-climbing runs succeed with probability 0.25. What is the expected number of runs through the first success?
  1. 3 runs
  2. 4 runs
  3. 5 runs
  4. 0.25 runs
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A simulated-annealing move increases a minimized cost by 3 at temperature 6. What is its acceptance probability, approximately?
  1. 0.223
  2. 0.607
  3. 0.500
  4. 1.000
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Genetic-algorithm parents are "253142" and "461325". A crossover cuts after the third digit and exchanges suffixes. What are the children?
  1. "253142" and "461325"
  2. "251325" and "463142"
  3. "253461" and "142325"
  4. "253325" and "461142"
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A maximizing local search starts at P, score 10. Allowed edits are P→Q (10), P→R (9), Q→V (10), Q→W (8), V→U (13) and V→Q (10). A goal needs score 13. What is the smallest consecutive-sideways-move limit allowing a goal without accepting a loss, and what landscape feature do P, Q and V form?
  1. 2; a shoulder
  2. 1; a shoulder
  3. 2; a flat local maximum
  4. 3; a strict local maximum
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

Each independent restart succeeds with probability 0.2. A failed run takes 6 moves and a successful run takes 10. What is the expected total number of moves through the first success?
  1. 30 moves
  2. 40 moves
  3. 34 moves
  4. 50 moves
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Two annealing runs face proposed cost increases. Run X has an increase of 4 at temperature 8; run Y has an increase of 2 at temperature 2. How do their acceptance probabilities compare?
  1. X is about 0.368; Y is about 0.607.
  2. Both are about 0.607 because both moves worsen cost.
  3. Both are about 0.368 because both temperatures are positive.
  4. X is about 0.607; Y is about 0.368.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Local beam search retains three states. From A, successor scores are A1 11 and A2 7; from B, B1 10 and B2 9; from C, C1 8 and C2 6. In the next round, A1 produces scores 13 and 5; B1 produces 12 and 11; B2 produces 10 and 9. After two rounds of best-three selection, how many survivors descend from the original A, B and C, respectively?
  1. 2, 1 and 0
  2. 1, 2 and 0
  3. 1, 1 and 1
  4. 0, 3 and 0
Show answerHide answer

Save this lesson to see this answer.

Set 5: Choose and diagnose search methods10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Every move in a finite puzzle costs 4 units. What does a shallowest solution minimize?
  1. Heuristic run time as well as move count.
  2. Reachable states as well as move count.
  3. Max branching factor as well as move count.
  4. Total path cost as well as move count.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A panel puzzle permits a special rotation only before a one-use latch has been pulled. Its state currently records only panel positions. What additional state information is needed?
  1. The number of nodes currently in the search frontier.
  2. Whether the one-use latch has already been pulled.
  3. The alphabetical order used to break search ties.
  4. The number of routes already tried by the planner.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Two routes reach a goal: one has 2 actions costing 14 in total; another has 4 actions costing 8. No heuristic is available. What strategy guarantees minimum cost under the positive-cost model?
  1. Uniform-cost search
  2. Breadth-first search
  3. Depth-first search
  4. Depth-limited search with limit 2
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

In cost-minimizing simulated annealing, a proposal lowers the cost by 5 while temperature is 0.1. How is that proposal handled?
  1. Accept it with probability 0.007.
  2. Reject it as temperature is low.
  3. Accept it with probability 1.
  4. Accept it only after a restart.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A robot moves horizontally, vertically or diagonally at unit cost. From (2,1) it seeks (7,4) on an obstacle-free grid. What are the exact remaining cost and the status of Manhattan distance at this state?
  1. Cost 8; Manhattan distance is exact.
  2. Cost 5; Manhattan distance overestimates.
  3. Cost 3; Manhattan distance underestimates.
  4. Cost 5; Manhattan distance is admissible here.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Directed edges are R→P 4, R→Q 1, Q→P 1 and P→Z 4. Estimates are R 0, P 0, Q 5 and Z 0. Alphabetical ties apply. What costs do A* without reopening and A* with reopening return?
  1. 8 without reopening; 6 with reopening.
  2. 6 without reopening; 6 with reopening.
  3. 8 without reopening; 8 with reopening.
  4. 6 without reopening; 8 with reopening.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A tree is a single chain with its first goal at depth 5. Count generated nodes below the root across all completed passes. How many does IDS generate through its successful pass, compared with BFS?
  1. IDS 5; BFS 5.
  2. IDS 20; BFS 5.
  3. IDS 15; BFS 5.
  4. IDS 15; BFS 6.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A table gives an admissible remaining-cost estimate. A second table is exact on a different relaxation and sometimes larger, sometimes smaller. Optimality is required, and the tables can count the same moves. How can both estimates be used safely?
  1. Add them where different tables win.
  2. Use their sum minus the path cost.
  3. Use the larger plus half the smaller.
  4. Take their maximum at every state.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A* uses a consistent heuristic. The optimum costs 12. Pending nodes X, Y and Z have priorities 10, 12 and 15; their values stay unchanged. What can be concluded about expansion before the optimal goal is returned?
  1. X must be expanded; Y may be; Z will not be.
  2. X and Y must be expanded; Z may be.
  3. Only X may be expanded; Y and Z will not be.
  4. X, Y and Z must all be expanded before return.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An annealing run uses unit temperature and faces a cost increase of 3. The objective is rescaled so every cost is multiplied by 100. What temperature preserves that move’s acceptance probability, and why?
  1. 1, because changing the units never changes the exponent.
  2. 100, because the increase-to-temperature ratio stays the same.
  3. 0.01, because temperature must offset cost by division.
  4. 300, because temperature must equal the new cost increase.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

84 Key Terms, each with its definition

A

A* search
A search* ranks pending paths by accumulated cost plus estimated remaining cost, returning a goal when it has minimum frontier priority.
A* search can leave a costly side branch unexpanded when its estimate places it above the optimal goal cost.
Abstraction
An abstraction removes details from a problem representation while keeping its proposed solutions possible to carry out.
A route abstraction can omit the car’s color when color changes neither road access nor travel costs.
Action cost
An action cost is the numerical cost of one transition, such as a road’s distance or one unit for a legal puzzle move.
The action cost of a road can be 6 km even when taking that road counts as just one search step.
Additive pattern heuristic
An additive pattern heuristic sums subproblem costs whose move-cost assignments avoid charging the same work more than once.
An additive pattern heuristic can combine disjoint tile patterns when each charges only moves of its own tiles.
Admissible heuristic
An admissible heuristic is a nonnegative estimate that never exceeds the true cheapest remaining cost and is therefore zero at a goal.
A zero-valued admissible heuristic is safe for A* but supplies no guidance beyond uniform-cost search.

B

Backtracking search
A backtracking search explores one successor at a time and returns to earlier choices when a branch ends, retaining only a path of states.
Backtracking search avoids storing every sibling at once when a state has many possible successors.
Beam search
A beam search retains only a limited number of promising candidates and discards the rest, potentially losing a necessary solution branch.
Beam search with width 3 can discard the fourth-ranked path even when it later proves to be the only route to a goal.
Bidirectional search
A bidirectional search explores forward from the start and backward from a goal, seeking a connection between the two searches.
Bidirectional search can save work on a two-way map when each search reaches roughly half the route’s depth.
Branching factor
The branching factor is the number of successors available at a node, with worst-case bounds using the largest such number.
A branching factor of 4 can produce 16 depth-two paths before duplicate checks remove overlaps.
Breadth-first search
Breadth-first search expands the shallowest pending node first and finds a fewest-action solution by exploring in depth order.
Breadth-first search finds a minimum-hop network route when every connection counts as one action.

C

Complete-state formulation
A complete-state formulation makes every state a full candidate answer, including candidates that still contain conflicts or have low quality.
A complete-state formulation of 8-queens places all eight queens before any improving move is considered.
Completeness
Completeness is the guarantee that an algorithm finds a solution whenever one exists, under the stated conditions on its search space.
BFS has completeness with finite branching because each finite-depth layer is eventually reached.
Consistent heuristic
A consistent heuristic is zero at goals and never exceeds one step’s cost plus the successor estimate, for every directed action.
A consistent heuristic permits A* to close a state permanently after expanding its cheapest path.
Cooling schedule
A cooling schedule specifies how annealing temperature changes over time, usually reducing it so worse moves become less frequent.
A geometric cooling schedule multiplies temperature by a factor such as 0.95 at each update.
Cost bound
A cost bound limits how expensive a returned solution may be, without requiring that its cost equal the optimum or the bound itself.
The weighted A* cost bound W times C* still permits a run to find the exact optimum.
Cost optimality
Cost optimality is the guarantee that a returned solution has the lowest total path cost among all solutions to the search problem.
BFS has cost optimality for unit-cost moves but can choose an expensive route when road distances vary.
Crossover
A crossover combines parts of two parent encodings to form children, potentially preserving useful blocks while creating new combinations.
A crossover after position four joins one parent’s first four queen rows to the other parent’s last four.
Cutoff
A cutoff is a depth-limited search result indicating that the boundary blocked further exploration, leaving deeper possibilities unresolved.
A cutoff at depth 3 calls for a larger limit if the search is to investigate routes requiring four steps.

D

Depth-first search
Depth-first search follows a deep pending path before trying alternatives, using a stack or recursive backtracking to control selection.
Depth-first search may inspect a long branch before returning to a goal only two steps from the start.
Depth-limited search
Depth-limited search is depth-first exploration that recognizes goals but does not expand nodes beyond a specified depth boundary.
Depth-limited search with limit 4 cannot reach a goal that requires at least six actions from the root.
Dominance
Dominance holds when one admissible heuristic is at least as large as another at every state, making it a consistently stronger lower bound.
Manhattan distance has dominance over misplaced-tile count because each displaced tile needs at least one move.

E

Early goal test
An early goal test checks a node when it is generated, allowing BFS to stop at its first newly generated goal after checking the root.
An early goal test lets BFS stop before expanding the final goal or generating a deeper layer.
Effective branching factor
The effective branching factor is the branching factor of a uniform tree matching a measured search node count at its solution depth.
An effective branching factor near 1 describes exploration much narrower than a broad uninformed search.
Evaluation function
An evaluation function assigns the priority used to select pending search nodes, such as g for UCS or g + h for A*.
Changing the evaluation function from h to g + h makes an expensive greedy detour less attractive.
Expansion
An expansion applies all legal actions to a node’s state and generates child nodes representing the resulting extended paths.
The expansion of a corner position in the 8-puzzle generates two children because the blank has two moves.

F

FIFO queue
A FIFO queue removes entries in the order they arrived, so new search nodes wait behind older entries already in the frontier.
A FIFO queue holds newly generated depth-two nodes behind the remaining depth-one nodes in BFS.
First-choice hill climbing
First-choice hill climbing samples neighbors individually and accepts the first improvement, avoiding evaluation of the whole neighborhood.
First-choice hill climbing is useful when a candidate has thousands of possible small edits to inspect.
Fitness function
A fitness function scores a genetic-algorithm candidate so selection can favor more successful members of the population.
A fitness function counting non-attacking queen pairs assigns 28 to a solved 8-queens board.
Frontier
The frontier is the collection of generated nodes waiting to be selected for expansion, also commonly called the fringe.
After the start is expanded, the frontier contains its newly generated successors awaiting their turns.

G

Genetic algorithm
A genetic algorithm searches with a population of encoded candidates, repeatedly selecting parents, combining them and mutating their offspring.
A genetic algorithm can encode one queen’s row per column as an eight-position string.
Goal test
A goal test decides whether a state meets the required condition, which can identify a particular state or a property of many states.
The queen-placement goal test checks that no pair of queens attacks, allowing several final arrangements.
Graph search
A graph search remembers reached states so it can avoid redundant paths and update a state when a better path is discovered.
On a road map with many cycles, graph search avoids expanding equal-cost returns to an already reached city.
Greedy best-first search
Greedy best-first search expands the node with the smallest remaining-cost estimate, ignoring the path cost already paid.
Greedy best-first search can favor a nearby-looking destination reached only after an expensive detour.

H

Heuristic evaluation cost
The heuristic evaluation cost is the computation needed to obtain an estimate for one state, which contributes to total search time.
A higher heuristic evaluation cost can outweigh a large reduction in the number of expanded states.
Heuristic function
A heuristic function estimates the cheapest remaining cost from a state to a goal, supplying domain knowledge to guide search priorities.
A heuristic function can give straight-line kilometers as a lower-bound estimate of remaining road distance.
Hill climbing
Hill climbing repeatedly selects a better neighbor and stops when its rule permits no improvement, without planning a full route through the space.
Strict hill climbing stops at cost 4 when all neighbors cost at least 4, even if a distant state costs zero.

I

IDA*
IDA* repeats depth-first searches bounded by estimated total cost, increasing each threshold to the smallest value pruned above the last one.
IDA* can progress from cutoff 8 to cutoff 11 when 11 was the smallest excluded priority.
Implicit state space
An implicit state space is specified by a start state and rules for generating successors, instead of by a stored list of all states.
The 15-puzzle uses an implicit state space because listing all reachable boards would require enormous storage.
Initial state
The initial state is the situation from which a search begins, before any action in the proposed solution has been taken.
For a sliding puzzle, the supplied tile arrangement is the initial state, even when many other boards are possible.
Iterative deepening search
Iterative deepening search repeats depth-limited exploration with increasing limits to combine shallowest solutions with depth-first storage.
Iterative deepening search can solve an equal-cost puzzle without retaining the entire breadth-first frontier.

L

Late goal test
A late goal test checks a node when it is removed from the frontier, preserving the queue’s ordering when deciding to stop.
The late goal test prevents UCS from accepting an expensive direct goal before a cheaper detour is explored.
LIFO stack
A LIFO stack removes the most recently added entry first, making newly generated children available before older pending alternatives.
A LIFO stack makes DFS continue into a child branch while the root’s other children remain pending.
Local beam search
A local beam search pools neighbors of several retained states and selects a new group from that pool, sharing progress among candidates.
Local beam search may retain several children of one promising parent and none from another parent.
Local optimum
A local optimum is a state whose nearby alternatives offer no better value, even though a better state may exist elsewhere.
A hill climber can stop at a local optimum with two queen conflicts while a conflict-free arrangement exists.
Local search
A local search improves one or a few candidate states through nearby changes, usually discarding the sequence of edits that produced them.
Local search can improve a complete timetable while keeping only a small number of candidate schedules.

M

Manhattan distance
The Manhattan distance adds absolute horizontal and vertical differences, giving an obstacle-free distance for unit horizontal and vertical moves.
For a tile two rows and three columns from its target, Manhattan distance contributes five to the puzzle estimate.
Misplaced-tile heuristic
The misplaced-tile heuristic counts numbered puzzle tiles outside their target squares, excluding the blank and ignoring how far each tile must travel.
The misplaced-tile heuristic gives 1 for a single displaced numbered tile regardless of its distance from its target.
Mutation
A mutation changes an individual position in a candidate encoding, adding variation beyond the combinations inherited through crossover.
A mutation can change one queen’s encoded row while leaving the other seven column entries intact.

N

Neighborhood
A neighborhood is the set of states reachable by one allowed local edit, determining the immediate alternatives a search can compare.
Moving one queen within its column defines a neighborhood of 56 states for an 8-queens candidate.

O

Objective function
An objective function assigns a numerical quality to a candidate state, defining whether the local search should maximize or minimize its value.
An objective function counting queen conflicts is minimized, while one counting safe pairs is maximized.
Optimal efficiency
Optimal efficiency describes A*’s necessary-expansion advantage among comparable forward searches using the same consistent heuristic, apart from ties.
Optimal efficiency does not mean A* always has the lowest runtime when heuristic computation is expensive.
Optimal-cost contour
An optimal-cost contour marks priority equal to the optimal solution cost, separating lower-priority-value paths from more expensive estimates.
With consistency, A* expands paths below the optimal-cost contour and may expand some paths tied on it.

P

Path cost
A path cost is the sum of the action costs along a path, used to compare complete routes and partial routes during search.
A three-road route with action costs 2, 3 and 4 km has a path cost of 9 km.
Path cycle check
A path cycle check rejects a successor already among the current node’s ancestors, preventing a search path from revisiting itself.
A path cycle check blocks S–A–S but still allows another branch to reach A later through a different route.
Pattern database
A pattern database stores exact costs of selected subproblems, computed in advance so a full search can obtain lower bounds by lookup.
A pattern database can track tiles 1 through 4 while treating other numbered tiles as interchangeable.
Plateau
A plateau is a connected region of equal objective value, which may have no improving exit or may be a shoulder with one.
Sideways moves can cross a plateau, but they can also revisit equal-value states without making progress.
Positive cost lower bound
A positive cost lower bound is a fixed value above zero that no action cost falls below, limiting steps within a bounded path cost.
A positive cost lower bound of 2 means a path costing at most 10 can contain at most five actions.
Precomputation
Precomputation performs reusable work before individual searches, exchanging up-front time and storage for faster later estimates.
Pattern-database precomputation is easier to justify when many puzzles share the same goal layout.
Predecessor
A predecessor of a state is a state from which an action can reach it, providing the reverse transitions needed for backward search.
On a directed map, a predecessor of city Z has a road into Z, even if no road leads back from Z.
Priority queue
A priority queue selects an entry with the best priority value, allowing cost-based search to choose the cheapest pending path.
A priority queue can remove a newly inserted cost-3 route before an older cost-8 route in UCS.

R

Random restart
A random restart begins a fresh local-search run from a newly sampled state, giving another chance to enter a useful search region.
A random restart can escape a poor basin after strict hill climbing has stopped at a local optimum.
Reached set
A reached set records generated states and their best known nodes, including states on the frontier and states already expanded.
UCS consults the reached set when a second route to a city might improve its stored cost.
Recursive best-first search
Recursive best-first search uses path-sized storage and recorded alternative priorities to decide when to back up and revisit another branch.
Recursive best-first search can regenerate an abandoned subtree after its stored alternative becomes the most promising route.
Relaxed problem
A relaxed problem removes restrictions on the original actions while keeping original solutions available, making its optimum a safe lower bound.
Ignoring walls creates a relaxed problem for a grid robot that still moves one horizontal or vertical cell at a time.
Reopening
Reopening returns an expanded state to consideration after a cheaper path reaches it, allowing that improvement to affect later paths.
A* may need reopening when an admissible but inconsistent heuristic exposes a better route late.
Ridge
A ridge is a rising landscape feature whose direction is difficult to follow using the available single local moves.
A ridge can block a hill climber when every allowed immediate move lowers the score despite better states ahead.

S

Search node
A search node represents a particular path to a state and stores the state, parent, incoming action and accumulated path cost.
Two search nodes can end at the same city while recording different routes and different costs.
Shallowest solution
A shallowest solution uses the fewest actions to reach a goal, without necessarily having the lowest sum of unequal action costs.
A shallowest solution with two long roads can cost more kilometers than a route with three short roads.
Sideways move
A sideways move changes the current state without changing its objective value, allowing a local search to move across a flat region.
A bounded sideways move policy can help a hill climber cross a shoulder without wandering forever.
Simulated annealing
Simulated annealing samples local moves and sometimes accepts a worse one, with that probability controlled by loss size and temperature.
Simulated annealing can leave a local minimum by accepting a temporary increase in a schedule’s cost.
SMA*
SMA* uses available memory for search, dropping worst frontier leaves when full and storing their backed-up values for later regeneration.
SMA* needs room for an optimal solution path to retain its admissible-heuristic optimality guarantee.
Solution depth
The solution depth is the number of actions from the root to a goal node; shallowest solution depth is conventionally written as d.
A solution depth of 3 describes three actions, regardless of whether those actions cost 3 or 30 units.
Space complexity
The space complexity of a search describes its maximum retained information, including pending paths and any stored reached records.
BFS’s space complexity becomes costly when a wide final layer keeps millions of frontier nodes alive.
State
A state describes one possible situation in a problem, including the information needed to determine legal actions and their results.
A robot’s state may include both its location and whether it carries the key needed to open a door.
Stochastic hill climbing
Stochastic hill climbing randomly selects among improving moves, possibly giving larger improvements a greater chance of selection.
Stochastic hill climbing can take a smaller improvement even when a steeper improving neighbor is available.
Straight-line distance
The straight-line distance between two positions measures their direct separation, ignoring route restrictions such as roads or walls.
Straight-line distance underestimates road distance when a traveler must follow a winding road around a lake.

T

Temperature
The temperature is the positive parameter controlling tolerance for worse annealing moves, with higher values permitting more exploration.
At a fixed cost increase, reducing temperature from 10 to 1 makes acceptance much less likely.
Transition model
A transition model specifies the resulting state after a legal action is applied to a particular current state.
In a sliding puzzle, the transition model swaps the blank with the tile beside it when the blank moves left.
Tree-like search
A tree-like search explores paths without a global reached table, sometimes checking only for states repeated on the current path.
A tree-like search can revisit a junction through a new route after the earlier route has been abandoned.
Triangle inequality
The triangle inequality for a search heuristic bounds the current estimate by the cost of one step plus the next state’s estimate.
An edge of cost 2 from estimate 7 to estimate 3 violates the triangle inequality used for consistency.
True remaining cost
The true remaining cost is the lowest actual cost of reaching any goal from a state, providing the reference value for admissibility.
A heuristic value of 9 overestimates when the true remaining cost is 7, even if most other estimates are accurate.

U

Uniform-cost search
Uniform-cost search expands the node with the smallest accumulated path cost and returns a goal when it is removed from the frontier.
Uniform-cost search can improve a pending city’s record after discovering a cheaper route through another city.
Uninformed search
An uninformed search uses the problem’s legal actions, goals and costs without estimating the cheapest remaining cost to a goal.
Uniform-cost search is uninformed search even though it carefully orders paths by their accumulated costs.

W

Weighted A*
Weighted A* uses g + Wh with weight W greater than 1 to emphasize the remaining estimate, trading exact optimality for a cost bound.
Weighted A* with weight 2 and an admissible heuristic can return an optimal route, although its guarantee allows twice the cost.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started