- Learn
- Computer Science & IT
- Computer Science
- Artificial Intelligence
- Uninformed and Informed Search
Uninformed and Informed Search
IntermediateLesson 2 of 10 in Artificial Intelligence Course
What you will learn
- 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 spaceName 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 algorithmUse 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 algorithmsJudge 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.
- Describe a search problem and its state space
- 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 searchExplore 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 searchExpand 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 searchTrace 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 oneCompare the uninformed strategies side by side, add bidirectional search, and pick a suitable strategy for a given problem.
- Run breadth-first search
- 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 searchDefine 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* searchTrace 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 memoryUse 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.
- Use a heuristic with greedy best-first search
- 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 consistencyCheck whether a heuristic never overestimates and obeys the triangle inequality, and explain why each property matters for A*.
- Invent admissible heuristics from relaxed problemsDerive 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 factorDecide 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.
- Test heuristics for admissibility and consistency
- 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 landscapeExplain 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 climbingRun 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 algorithmsAccept some worse moves with a probability that falls as the temperature drops, design a cooling schedule, and use populations with crossover and mutation.
- Describe local search and the state-space landscape
Uninformed and Informed Search study guide
1Frame 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, , gives the state after action .
- The goal test recognizes an acceptable state.
- The action cost function, , 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 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 reachable states from a fixed start. The 15-puzzle has . A complete 8-queens representation with one queen per column has 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 . 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
- Put the root in the frontier and reached table.
- If the frontier is empty, return failure.
- Remove the node with the smallest evaluation value .
- If its state is a goal, return that node.
- Expand it. Add each new state; for a previously reached state, replace its stored node only when the new path is cheaper.
- 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 , and 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:
| Symbol | Meaning |
|---|---|
| Maximum branching factor: successors per node | |
| Depth of a shallowest solution | |
| Maximum path depth, possibly infinite | |
| 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 and answers a different question from a bound for generating an unseen tree.
See why depth is expensive
A full tree through depth contains
nodes for . 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:
| Depth | Approximate nodes | Time | Memory |
|---|---|---|---|
| 6 | 1.1 million | 1 second | 1.1 GB |
| 8 | 111 million | 2 minutes | 111 GB |
| 10 | 11 billion | 3 hours | 11 TB |
| 12 | 1.1 trillion | 13 days | 1.1 PB |
These are decimal storage units: 1 GB is 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.
2Search 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.
2.1 Run breadth-first search
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 node | Newly reached states | Queue afterward |
|---|---|---|
| S | A, B, D | A, B, D |
| A | C | B, D, C |
| B | None | D, C |
| D | G, which passes the goal test | Search 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 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 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 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 can generate depth , giving the usual 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 .
2.2 Find the cheapest path with uniform-cost search
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 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 node | Update | Frontier afterward |
|---|---|---|
| S, 0 | Reach A, B, D | A 2; B 3; D 9 |
| A, 2 | Reach C via A | B 3; C 6; D 9 |
| B, 3 | Improve C through B | C 4; D 9 |
| C, 4 | Reach G | D 9; G 9 |
| D, 9 | G via D costs 11; keep 9 | G 9 |
| G, 9 | Goal test succeeds | Return |
The replacement of C is decisive: beats . 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 , 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 . On this map, and , giving . 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 bound. A* with makes exactly the same priority comparisons as UCS.
Key Takeaways
- UCS orders the frontier by accumulated path cost .
- 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.
2.3 Save memory with depth-first and iterative deepening search
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 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 and its stored paths and siblings need space. Backtracking that generates one child at a time reduces storage to . 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 and .
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 and space is .
Most nodes of a broad tree are in the last layer, so repeating the upper layers is often inexpensive. For and , count generated nodes below the root:
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 . 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 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.
| Strategy | Complete? | Cost-optimal? | Time | Space |
|---|---|---|---|---|
| BFS | Yes | Equal step costs | ||
| UCS | Yes, costs bounded below by positive | Yes | Same as time | |
| DFS | In finite spaces | No | ||
| Depth-limited | If the limit reaches a goal depth | No | ||
| IDS | Yes | Equal step costs |
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 . The work is then roughly instead of . 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.
3Search 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.
3.1 Use a heuristic with greedy best-first search
A heuristic assigns a state an estimate of the cheapest remaining cost to a goal. Write it as for the state in node . 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:
From cell (1,1) to (4,5), this gives moves. Straight-line distance between the same coordinates is . 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 . 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.
- Expand S. The frontier has A with estimate 7, B with 5 and D with 2.
- Remove D because 2 is smallest. Expanding D generates G with estimate 0. The path cost to G is km.
- 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 , 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 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.
3.2 Find optimal paths with A* search
A* evaluates the whole proposed journey: the cost already paid plus an estimate of what remains. Its priority is
Use a priority queue, replace more expensive paths and test a goal when it is removed. At a goal, , 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 node | What changes |
|---|---|
| S, | Add B with , A with and D with |
| B, | Add C with ; D via B is no cheaper |
| C, | Add G with |
| A, | C via A costs 6, worse than its stored 4 |
| G, | Return 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 . 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 were about to be removed. Some node on an optimal path must still be pending. For its optimal-path prefix,
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 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 , may expand nodes tied at 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 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 with . 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 . 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 ; 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 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 . 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 and can return a solution costing up to under its admissible-heuristic guarantee.
- Beam search discards candidates and can lose the only solution.
- IDA* raises its cutoff to the smallest exceeded value.
- RBFS and SMA* can regenerate forgotten work to limit memory.
- SMA* needs enough memory for an optimal solution path to guarantee optimality.
4Design 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 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:
| State | Estimate | True remaining cost |
|---|---|---|
| S | 8 | 9 |
| A | 7 | 9 |
| B | 5 | 6 |
| C | 4 | 5 |
| D | 2 | 2 |
| G | 0 | 0 |
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 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 , C→B gives and D→G gives . 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 on an optimal path, so consistency implies admissibility. It also gives
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: .
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, 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 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, .
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, . 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.
| Tile | Current position | Goal position | Distance |
|---|---|---|---|
| 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 . Their distances total , so . 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:
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 dominates admissible if 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 . 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, , describes the breadth of an equivalent uniform tree. Count generated nodes below the root and let the solution depth be . Solve
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 . For 1,000 generated nodes and depth 8, . 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
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 . 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.
5Use 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 states and 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 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 .
For four columns, the tuple (1,2,3,4) puts all queens on one diagonal. Its 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 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 count attacking pairs. Begin with (1,2,3,4), whose cost is 6.
- Evaluate the one-queen moves. A best neighbor is (2,2,3,4), with cost 4.
- From there, a best neighbor is (2,1,3,4), with cost 2.
- 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 , the expected number of runs through the first success is . For , that is about 7 runs. Using the reported step counts, expected total steps are
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 states, generates their neighbors together and retains the best 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 take 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 . If , accept the worse move with probability
For cost minimization, let be the increase in cost. A worse move then has and acceptance probability . 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 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 , acceptance probability is .
- 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
1Turn a problem into a search
13 steps
- 1IntroductionFrom 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.
- 2ExampleSpecify 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.
- 3ExplanationReturn 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.
- 4ChallengeKeep 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.
- 5Key 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 .
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.
- 6ExplanationStore 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 .
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.
- 7ExampleSeparate 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.
- 8ExplanationPropagate 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.
- 9ChallengeRecover 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.
- 10ExplanationAsk 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.
- 11ExampleWatch 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.
- 12ChallengeDo 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.
- 13RecapRead 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.
2Trace uninformed search on one map
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionOne map, several search orders
- 2ExampleStart the breadth-first queue
- 3ExampleLet the first goal appear
- 4ChallengeInterpret the BFS result
- 5TipUse the matching BFS bound
- 6ExampleOrder by cost already paid
- 7ExampleRemove the goal at minimum cost
- 8ChallengeWait for the cheaper unfinished route
- 9Key InsightBound the cost of endless depth
- 10ExampleFollow the depth-first branch
- 11ExplanationDistinguish a boundary from failure
- 12ExamplePay a small price for less memory
- 13ChallengeChoose a depth strategy
- 14ExplanationMeet a search from the goal
- 15ChallengeSelect by costs and reverse access
- 16RecapMatch the guarantee to the task
3Guide a search with estimates
15 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionEstimate the unfinished journey
- 2ExplanationGive the estimate a meaning
- 3ExampleLet apparent closeness choose
- 4ChallengeChoose between a cheap prefix and a small estimate
- 5ExampleAdd the two costs
- 6ExampleResolve the final tie
- 7Key InsightKeep an optimal route competitive
- 8ExplanationKnow when a closed state stays closed
- 9ChallengeDiagnose a missing improvement
- 10ExampleEmphasize progress toward the goal
- 11ExplanationRaise a cost contour instead of keeping a frontier
- 12ExampleMove the cutoff from eight to nine
- 13TipDecide whether forgotten paths can return
- 14ChallengeChoose a guarantee under limited memory
- 15RecapSeparate ordering, stopping and memory
4Build and check a safe heuristic
15 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionProve the estimate is safe
- 2ExplanationCheck the true-cost bound
- 3ExampleCheck a directed step
- 4ChallengeSeparate an optimistic estimate from a smooth one
- 5ConnectionLet the moves determine the distance
- 6ExplanationMake an easier problem deliberately
- 7ExampleRelax two puzzle restrictions
- 8ExampleCount the displaced numbered tiles
- 9ChallengeAvoid counting one move twice
- 10ExplanationPrecompute and combine lower bounds
- 11ExplanationCompare estimates everywhere
- 12ExampleFit an equivalent tree
- 13ExampleCharge for heuristic computation
- 14ChallengeUse two estimates without a dominance claim
- 15RecapJudge safety and usefulness separately
5Improve complete candidates
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionSearch for an arrangement
- 2ExamplePut every queen into the state
- 3ExampleCount attacking pairs
- 4ExplanationPicture the traps
- 5ChallengeDecide whether the edit history matters
- 6ExampleFollow the best immediate moves
- 7ExplanationTry sideways motion or a fresh start
- 8ChallengeInclude the successful run
- 9ConnectionShare progress without losing every alternative
- 10ExplanationAccept a temporary loss
- 11ExampleHold the loss fixed and lower temperature
- 12ChallengeKeep the signs consistent
- 13TipCool at a useful pace
- 14ExampleCombine two parent strings
- 15ChallengeDiagnose a stagnant population
- 16RecapChoose a way past the obstacle
Uninformed and Informed Search practice questions
Set 1: States, frontiers and uninformed search10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Heuristics, A* and memory limits10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
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
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
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
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
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
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
A* search
Abstraction
Action cost
Additive pattern heuristic
Admissible heuristic
B
Backtracking search
Beam search
Bidirectional search
Branching factor
Breadth-first search
C
Complete-state formulation
Completeness
Consistent heuristic
Cooling schedule
Cost bound
Cost optimality
Crossover
Cutoff
D
Depth-first search
Depth-limited search
Dominance
E
Early goal test
Effective branching factor
Evaluation function
Expansion
F
FIFO queue
First-choice hill climbing
Fitness function
Frontier
G
Genetic algorithm
Goal test
Graph search
Greedy best-first search
H
Heuristic evaluation cost
Heuristic function
Hill climbing
I
IDA*
Implicit state space
Initial state
Iterative deepening search
L
Late goal test
LIFO stack
Local beam search
Local optimum
Local search
M
Manhattan distance
Misplaced-tile heuristic
Mutation
N
Neighborhood
O
Objective function
Optimal efficiency
Optimal-cost contour
P
Path cost
Path cycle check
Pattern database
Plateau
Positive cost lower bound
Precomputation
Predecessor
Priority queue
R
Random restart
Reached set
Recursive best-first search
Relaxed problem
Reopening
Ridge
S
Search node
Shallowest solution
Sideways move
Simulated annealing
SMA*
Solution depth
Space complexity
State
Stochastic hill climbing
Straight-line distance
T
Temperature
Transition model
Tree-like search
Triangle inequality
True remaining cost
U
Uniform-cost search
Uninformed search
W
Weighted A*
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.