Uninformed and Informed Search
3.1 Search Problem Formulation Recap
3.1.1 The Five Components of a Problem
Hook: What do a road trip, a sliding puzzle, and a chess game have in common? In the early days of AI, for many years, people modeled real-world problems as search problems: define an initial state and a goal state, then apply a search technique to walk from one to the other — and the system has "done AI", it took itself to the goal. Every search algorithm in this lecture assumes the problem has already been shaped into these five components, so getting the shape right is where everything starts.
The agents that do this are called problem-solving agents (PSA). A problem-solving agent does not act on the first thing it sees; it plans ahead. It simulates sequences of actions inside a model of the world, searches until it finds a sequence that reaches the goal, and then executes that sequence for real. The sequence it finds is called a solution. The four-phase process is: goal formulation (adopt the goal), problem formulation (describe the states and actions needed to reach it), search (simulate action sequences in the model), and execution (carry the found solution out).
To model a problem this way, we must be able to produce five things for any question we are given:
- Initial state — where the agent starts, written . For the road trip: Arad.
- Goal state (or goal test) — what "done" looks like. Sometimes a single state (Bucharest); sometimes a small set; sometimes a property, as in a vacuum-cleaner world where the goal is "no dirt anywhere". A goal test answers the yes/no question "is this state a goal?" for any state.
- Possible actions — what the agent may do in each state. Written , it returns the finite set of actions applicable in state . Example: .
- Transition model — where each action leads. Written , it returns the state that results from doing action in state . Example: .
- Path cost — what each move costs. Written , it gives the numeric cost of applying action in state to reach state . For route finding, the cost of an action might be the road length in miles or the time it takes. Path costs are assumed additive: the total cost of a path is the sum of the individual action costs. An optimal solution is the solution with the lowest path cost among all solutions.
The professor's way of checking this: whatever question is given, you should be able to come up with these five components. Writing these five things down is what formulating a problem means.
The five-component contract. A search problem is fully described by: the initial state , the actions , the transition model , the goal test , and the action cost . The state space — the set of all reachable states plus the transitions between them — is the graph the search will move through. Search algorithms treat states as whole, atomic objects: the internal structure of a state is not visible to the search, only the five components above.
This sits on top of what was covered before: the PEAS specification (performance measure, environment, actuators, sensors), the different natures of the environment (is it partially observable? static or dynamic?), and the different types of agents (simple reflex, model-based, goal-based, utility-based, learning). A useful link back to the previous lecture: the five-component formulation only makes sense for the environments the search chapter assumes — episodic, single-agent, fully observable, deterministic, static, discrete, and known. If the world is dynamic or partially observable, the same five components still exist, but the search must be re-run or made contingent on what the agent observes.
3.1.2 Worked Examples of Formulation
Example 1 — Road trip (Arad to Bucharest). On the Romania map, if the agent is in Arad and must reach Bucharest:
- Initial state: Arad.
- Goal test: checks whether the agent is in Bucharest.
- Actions: the roads out of the current city — from Arad, exactly the set of reachable cities: Sibiu, Timisoara, Zerind.
- Transition: says which city each road leads to; .
- Path cost: the road distance in miles (for example Arad → Sibiu = 140, Arad → Zerind = 75).
If I am in Arad, the actions are exactly the set of reachable cities, and each has its own edge cost.
Example 2 — The 8-puzzle (sliding puzzle). A 3 × 3 grid holds eight numbered tiles and one blank space; the goal is to reach a specified arrangement.
- Initial state: any given start arrangement.
- Goal test: does the arrangement match the target arrangement? The start state and goal state supply the first two properties by themselves.
- Actions: the transitions are strictly constrained — the blank tile can only move up, down, left, or right. Nothing else is allowed; you cannot randomly pick up tile 7 and drop it somewhere else. From a given arrangement, only tiles 2, 5, 6, or 3 can move (down, left, right, up, depending on where the blank sits).
- Transition: swapping the blank with the neighboring tile in the chosen direction; for example, moving the blank Left swaps it with the tile to its left.
- Path cost: each move costs 1.
Repeating such moves generates the whole state space — the transition diagram drawn in class — and if you keep applying legal moves you eventually cover it. The 8-puzzle has 9!/2 = 181,440 reachable states, which is why its state space is small enough to draw small pieces of, and large enough to be a classic benchmark.
One subtle point about formulating problems: abstraction. The five components are a model, not the real thing. "Arad" in the model leaves out the radio program, the scenery, the weather, and the traffic — all irrelevant to finding a route. A good problem formulation removes as much detail as possible while keeping a solution easy to carry out: the action "drive from Arad to Sibiu" is useful; "move the right foot forward one centimeter" is not. Formulating a problem is an act of judgment, not just transcription.
3.1.3 Learning Outcomes and Probable Questions
The professor listed the skills this material is expected to produce, which are also the probable question types so far:
- Given a situation (for example, "you are playing chess"), explain the environment: all the aspects from the environment taxonomy.
- Given a situation, argue which agent architecture is best suited — is a reflex agent enough, or do you need a goal-based, utility-based, or more capable design?
- Given a problem, formulate it using the five definitions: initial state, actions, transition, goal, and path cost.
Scope and common traps. The five-component formulation assumes additive, positive path costs — the total cost of a path is the sum of its steps, and each step costs more than zero. If an edge could be negative, the notion of "cheapest path" becomes ill-defined on cycles. Also note the difference between a tree and a graph: this course mostly deals with graphs, but a tree is a special kind of graph (one unique path between any two nodes), so every example on a tree is also a valid graph example. Finally, do not confuse the goal test (deciding whether you have arrived) with the goal state (a specific state you might arrive at) — the test is the yes/no function, the state is a particular destination.
Exam note: these are the probable learning outcomes to check yourself against: PEAS, environment judgment, agent-architecture choice, and five-component problem formulation. A likely exam question is exactly the drill above: take a situation, produce the five components, judge the environment, and argue for an agent architecture. Practice on the road trip and the 8-puzzle until the five items come out instantly.
Real-world connection: this formulation style is not classroom decoration. Route-finding web sites and in-car navigation systems are direct extensions of the Romania example — states are locations, actions are roads, costs are travel time. The same five components drive airline travel-planning systems (states there include airport and time, and the action cost mixes money, waiting time, and flight time), robot navigation (states are positions and joint angles), and touring problems such as the traveling salesperson problem, where the goal is to visit every city. Whatever the domain, the agent first needs a well-formed problem — the five components — before any of the search techniques in this lecture can start.
3.2 Uninformed versus Informed Search
3.2.1 Two Categories of Search
Hook: You have a problem modeled as a search problem — now you must search. You can search with no help at all, grinding through everything the problem hands you, or you can search with a guide that whispers "this way looks more promising". That single choice splits all of search into two families, and every algorithm in this lecture belongs to one of them.
Broadly there are two categories: uninformed and informed search. Uninformed algorithms have no information apart from the given problem — the initial state, the goal state, the transitions, and the path costs of the graph they are handed. That is all they may use. They cannot look at a state and guess how close it is to the goal. Informed algorithms get extra information — an estimate that comes from outside the problem — and this extra information is called a heuristic. The name says it: an informed search is being informed, it has something beyond the raw problem statement.
A good way to feel the difference: the uninformed agent in Arad has no clue whether Zerind or Sibiu is the better first step, because it has no knowledge of Romanian geography. An informed agent who knows where each city lies knows Sibiu is far closer to Bucharest and is more likely to be on a shortest path. Same problem, same graph — the only difference is that extra hint.
3.2.2 The Comparison Table
The professor presented a comparison table between the two families (values transcribed as stated; the completeness row was delivered unclearly, so the standard treatment from the reference is given and marked):
| Dimension | Uninformed search | Informed search |
|---|---|---|
| Knowledge use | Does not use any knowledge during the search process | Uses knowledge during the search, supplied by a domain expert or fed in by you |
| Completeness | It is always going to complete — but it can be complete and incomplete | It can be complete and incomplete |
| Efficiency | Costs more, generates slower results — comparatively less efficient, searching blindly | Costs less, generates quicker results — more efficient |
Completeness means: are you able to find the goal state or not? The standard treatment: completeness is a property of the specific algorithm, not the family. Among uninformed algorithms, breadth-first search, uniform-cost search, and iterative deepening are complete (BFS and UCS whenever a solution exists, on finite state spaces; UCS with positive step costs); depth-first search is not complete in general. Among informed algorithms, greedy best-first graph search is complete on finite state spaces but not on infinite ones, while A* is complete when its heuristic conditions hold. So "can be complete and incomplete" is true for both families — the row depends on which member of the family you pick and what the state space looks like.
Efficiency is where the families truly differ in spirit. Uninformed search costs more and generates slower results because it explores in the dark; informed search spends less and reaches answers quicker because the heuristic prunes away unpromising paths. The professor's framing: uninformed methods are often called blind searches — you are given just the problem and you grind through it.
3.2.3 Student Questions
Q: Can uninformed search be described as random exploration?
A: Not random in that sense. BFS uses a queue, DFS uses a stack, and so on — each algorithm has its own systematic rule. The better wording is: uninformed search has no extra information, it works only with the given problem, while informed search has that extra piece of information, the heuristic.
Q: Will iterative deepening end up similar to BFS then?
A: It is actually BFS and DFS only — iterative deepening and iterative lengthening are the same BFS and DFS, but done in a controlled fashion. That is all they are. Iterative deepening runs DFS with growing depth limits; iterative lengthening runs BFS or UCS with growing cost limits. Neither is a new species of algorithm; both are the old ones wearing a leash.
Q: When we increase the depth, does it start again from the root? That looks like wasted work.
A: There is no real reason to restart from the root — you already know the goal is not among the nodes you explored at the smaller limit. Many textbook implementations are written that way so that students can understand the idea; the diagrams are for understanding too. Technically you can start from the frontier you already have, and more optimized versions explore partial regions of the graph or the adjacency matrix.
3.2.4 Why Move to Informed Search
All the uninformed methods — BFS, DFS, UCS, iterative deepening, iterative lengthening — are slow, and are often called blind searches. You are given just the problem, and you grind through it. The professor's framing: in life, when you are in a difficult situation you do not try to solve it alone; you go to a therapist, a mentor, someone experienced who can guide you. That guidance can help you do better — or it may lead you into a worse situation — but at least you have extra information to navigate by. The same thing holds in the AI world: this extra information or intuition is called a heuristic, it comes from domain experts, and the class of algorithms that use it is called informed search. Informed search, the name itself says it: I am being informed, I have extra information apart from the given problem.
The goal of informed search is to be smart about which paths to try, instead of doing the hard work of visiting every node — which is traversing the whole tree or graph. My goal is not to touch all of them; my goal is to go from the green node to the red node by choosing the more promising path. A node is selected for expansion based on an evaluation function that estimates the cost to the goal. Different informed algorithms differ only in what that evaluation function contains — this is exactly the difference between greedy best-first search and A* later in the lecture.
Exam note: the uninformed-search animations on the course materials are not exam questions, but they form the basis of these traditional AI techniques. The advice: play with them, put in your own input, watch how BFS, DFS, UCS, and iterative deepening explore — this basis is needed before informed search makes full sense. The data-structures material on the course page is only relevant if you do not come from a CS background and have no idea about queues and stacks; otherwise you can skip that whole thing.
A bridge to the next topics: the rest of the uninformed family — BFS, DFS, UCS, and iterative deepening — are each a specific rule for which node to expand next. Once we meet informed search, each of those rules gains a cousin that uses the heuristic: greedy best-first search expands the node with the smallest heuristic value, and A* expands the node with the smallest value of cost so far plus heuristic. Knowing the uninformed rules first makes the informed cousins easy to understand.
3.3 Breadth-First Search (BFS)
3.3.1 What BFS Does
Hook: You are told to search a tree and the goal could be anywhere. Do you charge down the first path you see, or do you sweep carefully, level by level, making sure no shallow node is missed? Breadth-first search is the cautious answer — and its caution is both its strength and its weakness.
Breadth-first search (BFS) is the more cautious of the two classic techniques: it examines paths of length before it examines paths of length . It visits a tree or graph level by level — it covers one full level, then the next, then the next. It uses a queue to do the visit, which is FIFO: first in, first out. The name says it: breadth first — cover all nodes at a given depth before proceeding to deeper nodes. All the algorithms discussed in the first part of this topic are uninformed: they only have the graph, possibly with path costs, and nothing else.
Purpose. BFS answers "is there a path to the goal, and what is the path with the fewest actions?" It is the right tool when all actions cost the same (for example, every move of the 8-puzzle costs 1) and you want the shallowest solution. It is also complete: if a solution exists at any finite depth, BFS will eventually find it, because it never skips a level.
Inputs and outputs. Input: the problem's five components (initial state, goal test, actions, transition model, path cost) with uniform step costs. Output: a solution path from the initial state to a goal, found by expanding nodes in order of increasing depth.
Because new nodes are always deeper than their parents, a FIFO queue gives exactly the right order with no extra bookkeeping: old, shallow nodes sit at the front and are expanded first; new, deep nodes join the back. The search also keeps track of reached states so that a state reached once is never reached again — without that check, a cycle like Arad → Sibiu → Arad would let the search loop forever.
3.3.2 Worked Example — Queue Trace
Worked example: BFS from A to F on a small tree. Consider a tree with root . 's children are and ; has children , and has children . The goal is , and we want to go from to . Level 0 contains ; levels 1, 2, ... hold its children. The queue works like this:
- Start with . Remove and ask: where all can take me? To and . Add them: . The order is not important — writing is not wrong.
- Remove . Where can take me? To . Add them: .
- Remove . Where can take me? To . Add them: .
- Remove . It cannot take us anywhere. Remove . Nothing either. Remove — and that is when we realize we are at the goal.
Because we removed nodes in the order they were added, every node of level 1 was removed before any node of level 2. That is why this is called breadth-first ordering — the traversal looks like: cover one level, then the next, then the next, and so on.
Sense-check: the goal appears twice in the queue (once via , once via ). BFS stops at the first it removes, which sits at depth 2 — the shallowest possible depth for , since is a child of level-1 nodes. A depth-first search could have reached via at the same depth but in a different order; BFS is the one that never looks at level 3 before finishing level 2.
A second, textbook-style view uses colors: the orange nodes have been covered (explored); the gray nodes have been generated but not yet explored — we have not gone there yet. You generate all nodes at a given depth before moving deeper. If the node we are currently at is the goal, we stop there and do not go further; exploring the goal further is unnecessary. The goal can be any node — anything can be a final goal, that is decided in your problem formulation (initial goal, final goal).
3.3.3 The Branching-Factor Problem
BFS has a real weakness. A branch factor is how many children a node has — in this example has two children. Suppose has 2000 children, and the goal is somewhere deep on the other side. BFS will first have to go through all 2000 children before it can even come to the next level. If the goal is somewhere beyond them, we waste a lot of time and memory in the full exploration of all the siblings of those nodes. That is one problem with BFS — a branch problem: high branch factor means slow progress toward depth.
Q: What if the goal is somewhere shallow but a node has many branches?
A: Exactly the difficulty: with a big branch factor you must traverse all those branches before reaching the next level, so you waste space and time when the goal is actually right behind them.
The cost of that caution is easy to see on a uniform tree where every node has children. The root generates nodes, each of those generates more, giving nodes at level 2, at level 3, and so on. If the solution sits at depth , the total number of nodes generated is
so both time and space complexity are . Those exponential bounds are the practical killer: with branch factor , a million nodes processed per second, and 1 KB of memory per node, a search to depth 10 takes less than 3 hours but needs about 10 terabytes of memory. BFS's memory demand is usually the bigger problem — it keeps every generated node until the search ends. This is the sense in which BFS "wastes space and time" when the goal is shallow but the branch factor is large.
3.3.4 Applications
Real-world: BFS is used for finding a path in a graph and for finding many solutions of a problem. There is a concept in graph theory called bipartition — a graph whose nodes split into two groups such that every edge runs between the groups — and BFS suits those problems too: color the start node red, its neighbors blue, their neighbors red, and a graph is bipartite exactly when this alternation never creates a conflict. The professor notes these two classic searches are fundamental; both are perfectly useful for particular applications and neither is "better" — they are suitable for different problems, which is more of a data-structures viewpoint.
When to use BFS — and when not. Use BFS when all step costs are equal and you want the fewest-actions solution (8-puzzle, word-ladder puzzles, finding the shortest path in an unweighted grid). Avoid it when step costs differ — BFS's "shallowest first" rule is then no longer "cheapest first", and uniform-cost search is the right tool. Also avoid it when the tree is wide: a high branching factor makes BFS sweep every sibling before making progress, wasting time and memory. And remember the classic BFS traps: it is complete and optimal only for uniform action costs, and its space requirement can exhaust memory long before time does.
Recap + bridge. BFS is the cautious level-by-level searcher: complete, optimal when all actions cost the same, but expensive in both time and space when the branching factor is high. That weakness — slow progress toward depth — is exactly what the next algorithm, depth-first search, attacks from the opposite direction.
3.4 Depth-First Search (DFS)
3.4.1 What DFS Does
Hook: BFS finishes a whole level before peeking at the next. What if the goal is deep — or the tree is so wide that sweeping a level is painful? Depth-first search takes the opposite bet: grab one path and plunge. It is the aggressive counterpart to BFS's caution.
Depth-first search (DFS) catches hold of one path and goes as deep as possible. When it realizes it cannot go any further, it comes back — backtracks — and tries another path. It maintains a stack (LIFO: last in, first out) to do this, instead of a queue. BFS was cautious: complete one level, then go to its children. DFS is the opposite: from a node, plunge immediately into the first child, then that child's first child, and so on until you hit a dead end.
Purpose. DFS answers "is there any path to the goal at all?" and, in many domains, finds one fast with very little memory. It is the tool of choice when the goal is likely to be deep and the state space is a tree — classic tree-like search without a reached-state table keeps only the current path in memory.
Inputs and outputs. Input: the problem's five components (a stack replaces the queue; path costs may be ignored entirely). Output: the first solution path DFS stumbles upon — there is no promise that it is the cheapest or the shallowest, only that it is some path to the goal.
The stack is what makes DFS what it is. The node added most recently sits on top, so the next expansion always dives into the newest frontier node — the deepest one — instead of the oldest, as a queue would. Since new children are pushed after their parent is expanded, the search immediately descends toward the leaves.
3.4.2 Worked Example — Deep Dive and Backtrack
Worked example: DFS on the same tree as BFS. Same tree: root with children ; has children , and has children . Goal , start .
The stack trace, step by step:
- Start: . Pop ; push its children (assume on top): .
- Pop ; push its children ( on top): .
- Pop . It has no children — a dead end. Stack: .
- Pop . Dead end. Stack: .
- Pop . This is the goal — stop.
The visited order is : plunge to , discover a dead end, backtrack to , dead end again, backtrack to — the goal. In words, from we go to ; from we immediately go to ; at we realize we cannot go any further, so we go to (the next unexplored child of ); then we move to ; from we go directly to ; from , knowing we cannot go anywhere, we go back to , then to . The contrast with BFS is very clear: in BFS, after we went to — we wanted to complete the level. In DFS, from we jump straight to the deepest reachable node.
Sense-check: with a stack, the frontier never holds more than one path's worth of siblings (one branch of the tree at a time), which is why DFS uses so little memory compared with BFS's full level of nodes.
The professor's second look at the same tree shows the aggressiveness even better: from we jump straight to , and from we jump to ; when we cannot go further from , we explore ; has no children — it is a leaf node — so we jump back to , and from we go to , then , and so on. We catch hold of something very deep and, as long as there is a path, we go there aggressively; when we can go no further, we stop and backtrack.
3.4.3 The Depth Problem
Suppose is the goal. When will DFS actually reach ? It will, eventually — but only after the deep dive. If also has a child , and has children, and so on — a structure called a skewed tree, with many children in one direction — DFS gets into a loop of going deeper and deeper, and the goal, which is off to the side, is missed for a long time. This is the opposite of BFS's problem: in BFS we explored sibling branches and wasted time; here it is not a branch problem, it is a depth problem. We keep going deep in one direction and only when we reach the leaf do we come back and eventually reach .
The memory benefit of DFS is real, though: a tree-like DFS without a reached table keeps only the current path, so space is , where is the branching factor and is the maximum depth of the tree. Problems that would need exabytes of memory under BFS can be handled with kilobytes under DFS. But the price is that DFS is not complete in general — in a cyclic state space it can loop forever (unless cycles are checked), and in an infinite state space it can wander down an infinite path. It is also not cost-optimal: it returns the first solution it finds, even if another path is far cheaper.
Neither algorithm is discarded: both have benefits. If the graph is small, nothing of this really matters — they are all the same on small inputs. And each has particular applications where it shines.
3.4.4 Applications
Real-world: DFS is intuitively better for connectedness questions. Suppose we want to know whether two people, call them X and Y, are friends in a social network graph. Catch hold of one of them and do DFS: go as deep as possible along one path — X → friend A (a dead end) — then backtrack and take another: X → friend B → friend C → Y. If we meet the other person's name anywhere along a path, they are connected; otherwise they are not. DFS answers this more simply than BFS. Similarly, topological sort in sorting techniques can be done with just DFS, and it will always give you the topological ordering — list tasks so that every task appears after all of its prerequisites. These are just two examples; a lot of things can be done with these two searches.
When to use DFS — and when not. Use DFS when memory is tight, when the goal is expected deep in the tree, or when any solution will do (connectedness checks, topological sort, and the maze-style problems discussed with iterative deepening). Avoid it when you need the shortest path, when the tree is skewed toward the wrong direction (the goal sits off to the side of a very deep branch), or when the state space has cycles — a naive DFS can circle forever inside a loop. The classic traps: DFS is neither complete (on infinite or cyclic spaces) nor cost-optimal (first-found is not cheapest).
Recap + bridge. DFS is the aggressive plunger: one path, as deep as possible, backtrack only at dead ends. It trades BFS's completeness and optimality for drastically smaller memory, and it pays for that with the depth problem — a skewed tree can hide the goal for a long time. Both weaknesses — BFS's branch problem and DFS's depth problem — are what the next two techniques, uniform-cost search and iterative deepening, are designed to fix.
3.5 Uniform Cost Search (UCS)
3.5.1 Definition and Rules
Hook: BFS finds the path with the fewest steps — but fewest steps is not cheapest. What if one road is long and slow and another is short? Uniform cost search answers that by replacing "shallowest" with "cheapest".
Uniform cost search (UCS) is also called cheapest first. It is essentially BFS, but with costs. Instead of expanding the shallowest node, UCS expands the node with the lowest path cost — the sum of edge costs from the start node to . Two rules matter:
- Sort the frontier. Whenever we put something into the queue, we should immediately sort the queue. Otherwise we get misled: the node at the front of the queue might have a higher cost than something behind it. So we sort again and again, then pick the first element. The frontier is whatever is in the queue right now. We are not forced to use a priority queue — a normal queue that we sort works; a priority queue implemented with a min-heap would also always give you the minimum at the start, but any data structure is fine as long as the order is sorted.
- Test the goal during expansion, not during generation. When we generate a new node (discover that it exists as a successor), we do not stop, even if it is the goal state. We only claim the goal when that node is expanded — pulled off the queue for exploration.
Purpose. UCS finds the lowest-total-cost path in a graph with arbitrary (positive) step costs. Where BFS spreads out in waves of uniform depth, UCS spreads out in waves of uniform path cost: it considers all paths systematically in order of increasing cost, never getting stuck down one path, and the first goal node it expands is guaranteed to be the cheapest one.
Inputs and outputs. Input: the five problem components with positive action costs . Output: the cost-optimal solution path — the first goal node popped off the frontier.
The evaluation function. Each node carries its path cost
— for the start node . UCS is best-first search with : always expand the node with the smallest .
The weights are actual, measured quantities: kilometers, miles, or fare — they come from real empirical data of the problem at hand, not from any estimate.
3.5.2 Worked Example — Romania
Worked example: UCS from Arad to Bucharest. Start: Arad. Goal: Bucharest. This is a simplified variant of the Romania map with the following road costs: Arad → Rimnicu Vilcea = 80, Arad → Fagaras = 99, Rimnicu Vilcea → Pitesti = 97, Pitesti → Bucharest = 101, Fagaras → Bucharest = 211.
- Queue is empty. Expand Arad: generate Rimnicu Vilcea (cost 80) and Fagaras (cost 99). Already sorted: .
- Expand the front: Rimnicu Vilcea (80). It can only take us to Pitesti: . Insert into the sorted queue: .
- Expand Fagaras (99). It can take us to Bucharest: . We know Bucharest is a goal state, but we do not test during generation — so Bucharest goes into the queue like any other node: .
- Expand Pitesti (177). It also takes us to Bucharest: . Queue: .
- Expand the front — Bucharest at 278. Now we are at the goal, so we stop.
The path found is Arad → Rimnicu Vilcea → Pitesti → Bucharest with total cost 278. Note what rule 2 just did: the search generated a Bucharest node at cost 310 while expanding Fagaras (step 3), but refused to stop there. If the goal test had run at generation, UCS would have returned the 310 path — suboptimal by 32. Waiting until expansion is exactly what guarantees the cheapest path.
Sense-check: every frontier node not yet expanded has cost at least 278 (the queue held ), so no hidden cheaper route to Bucharest can exist — the first expanded goal is optimal. We kept asking each node "where all can you take me, and at what cost?", inserting successors in sorted order of total cost, always removing the smallest, and waiting until we actually reached Bucharest by expansion — "when we reach the goal, we wait for the best path."
3.5.3 Student Questions
Q: Do we need a priority queue for this?
A: No. We are using a normal queue and sorting it after every insertion. A priority queue (a min-heap) is another way to always get the minimum at the start, but let's not go into heaps — the point is just that the queue stays in sorted order, whether you insert in order or sort each time.
Q: What are the weights — computational costs?
A: They are natural quantities: could be kilometers, could be the fare taken, and so on. They come from actual empirical measurement of the domain.
Q: If we remove the previous node from the queue, how does the search remember the path later?
A: Removing from the queue is not deleting the path. Wherever we have taken that path, we already store it and keep it; the final path and its cost are kept track of separately. Removal from the queue is only about what to explore next.
Q: Is the least cost always preferable?
A: Of course, depending on the problem — if you want to reach the goal at the lowest cost, this is preferable. But in some problems maximization is the goal: suppose the graph edges are money you gain — then you want to maximize. What the algorithm does stays the same: add the sum, put it in the queue, remove the lowest, explore it, and keep doing that until you are at a goal.
Q: What if the 211 edge were 150 instead?
A: You would keep exploring: add the sum, insert into the queue, remove whoever is lowest, explore them — the same logic, until you reach a goal. Whether the result is optimal is a separate question — that is not part of what we are checking here.
Q: There's a branch from Pitesti too — will it be considered?
A: Yes, whatever branches exist are expanded and their successors go into the queue. That is uniform cost search.
3.5.4 Where UCS Stands
At the end of the day UCS is nothing but BFS plus costing — the sorting on top. The known costs: memory usage is more, complexity is more, and so on. The worst-case time and space complexity is , where is the cost of the optimal solution and is the smallest step cost. When all step costs are equal, reduces to and UCS behaves like BFS. The exponent shows why UCS can be expensive: it will happily explore large trees of cheap actions before touching a single expensive-but-useful edge.
When to use UCS — and when not. Use UCS whenever step costs are not all equal and you need the cheapest path — its first expanded goal is guaranteed cost-optimal. Skip it when all costs are equal (BFS is faster and does the same job), and keep in mind the memory bill: like BFS, UCS keeps all reached nodes, so space is exponential in the solution cost. The classic trap is testing the goal at generation — doing so can return a suboptimal path, as the 310-vs-278 example shows.
Recap + bridge. UCS is BFS with a sorted frontier: expand the node with the smallest , test the goal only at expansion, and the first goal you expand is the cheapest. A connection to look ahead to: UCS and Dijkstra's algorithm are the same thing (single-source shortest path), while A* extends the idea further with a heuristic — . Meanwhile, BFS's branch problem and DFS's depth problem still exist for UCS's cousins, and the next technique attacks both at once.
Real-world connection: UCS is exactly what a "cheapest-first" planner needs when costs are real measured quantities — route planning by kilometers or miles, fare minimization, and any graph problem where the edges carry empirical prices rather than unit steps. Because it is Dijkstra's algorithm under an AI name, every industrial shortest-path problem (network routing, logistics, GPS precomputation) is a uniform-cost search in disguise.
3.6 Iterative Deepening Search
3.6.1 The Idea
Hook: BFS suffers when the tree is wide; DFS suffers when the tree is deep or skewed. What if you could run DFS — with its tiny memory — but in BFS's careful level-by-level style? That is the whole trick of iterative deepening search.
BFS has the branch-factor problem: with many branches we explore everything at one level before the next, wasting space and time. DFS has the opposite problem: the goal may sit somewhere in the breadth, but because DFS is aggressive it catches one path and keeps going, wastes space and memory, and may reach the goal too late — or not be optimal. Iterative deepening search (IDS) fixes both by applying DFS, but iteratively, with a growing depth limit. We show the graph only partially: first only the node at limit 0; then the children at limit 1; then one more level at limit 2; and so on, until the goal is found. The professor's explanation: "I will show you the graph partially — I'll hide the graph for you. First I'll show you only limit 0, then the first level, then the second level of children. I'm applying DFS in an iterative fashion so I don't get into that worst case where I keep going in one direction and get lost." We are not deciding a limit ahead of time — we start at zero and increment until we find the goal.
Purpose. IDS gives the memory advantage of DFS and the level-by-level safety of BFS at the same time. Each iteration is a depth-limited search: run DFS, but treat every node at depth equal to the limit as if it had no successors, so the search can never dive past the limit.
Inputs and outputs. Input: the five problem components. Output: a solution path, complete whenever a solution exists at finite depth and the search checks for cycles. The cost: nodes near the top of the tree are regenerated on every iteration — the children of the root are generated times, the next level times, and so on — giving total nodes
the same asymptotic time as BFS, but with memory only — the current path plus its siblings, not a whole level. With : IDS generates nodes versus BFS's — barely more, for a fraction of the memory.
3.6.2 Worked Example — Growing Limits
Worked example: IDS on the class tree. Root with children ; the goal is set deep in the tree, and the point is that DFS alone would dive too far in the wrong direction.
- Limit 0: only . Is this the goal? No. Increase the limit to 1.
- Limit 1: from go to , then to — both checked, neither is the goal. Increase the limit to 2.
- Limit 2: from to , from to , from to ; are not the goal, so come to , check it, then , then — still not the goal. Increase the limit again.
In each iteration DFS runs, but only within the allowed depth, so we never get stuck in the deep loop: "There is a path here, it's a big graph, but I'm slowly, level by level, applying my DFS."
Sense-check: at every limit, the deepest node touched is exactly the limit. A skewed branch like cannot swallow the search at limit 2, because depth-3 nodes are invisible to it; the goal , if it sat at depth 1, would have been found at limit 1 instead of after a long dive. If the limit increments by one each round, no goal is ever skipped, and the first iteration that reaches the goal's depth finds it.
3.6.3 Iterative Lengthening Search
If we can do DFS iteratively for the depth problem, can we do the same for the branch problem? Yes — that is iterative lengthening search: instead of increasing the depth limit, we increase the cost limit and run BFS (or UCS) within it, showing the graph partially and expanding when no goal appears. It can be described as a modification of UCS or BFS that runs iteratively. In the same way, iterative lengthening is not as bad as regular BFS in the worst cases: with a 2000-child node, iterative lengthening shows only part of the structure at a time and expands when no goal is found, so it never sweeps all 2000 siblings before making progress.
3.6.4 Student Questions
Q: Are we visiting nodes again and again in every iteration?
A: Not really. The diagrammatic view (restarting from A each time) is just for you to understand that at limit 2 we explore one more level of children. In reality, once we have visited A, B, C and know none of them is the goal, the next iteration technically starts from the children of B — we do not restart from the root every time.
Q: Still the same issue if a node has 2000 children?
A: No, that is the whole point — because we are going level by level. And conversely, if you want to handle the 2000-branch case with BFS, iterative lengthening shows only part of the structure at a time and expands when no goal is found.
Q: How do we maintain this level limit in a real graph?
A: A graph can be represented in many ways — an adjacency list or an adjacency matrix. Suppose we use a matrix: we apply DFS only to a small region of the matrix first, and if no goal is found we expand the region. The matrix itself is the copy of the graph.
Q: Will iterative deepening use more memory?
A: No, memory-wise it is the same. Even in a regular graph, at the end all the nodes are in memory; here too. We are just exploring in a more controlled environment — that is the whole point.
Q: Can it still hit a worst case?
A: Of course — any algorithm has a worst case. But this is at least not as bad as regular DFS, and iterative lengthening is not as bad as regular BFS. Guardrails are in place, and empirically IDS is better than plain DFS and BFS.
3.6.5 Choosing a Search Algorithm
Q: How can we figure out which algorithm should be chosen for a problem? Is there a straightforward way?
A: No, there is no such easy way — and that is one reason algorithms themselves have started to learn, which we will see later in the course: they will figure out what to do. But there are intuitions. Take a maze problem: a rat at one end, food at the other. From the rat, will you explore all the paths level by level, or will you try to go as deep as possible toward the food? You take a path, the rat goes deep, gets stuck, you erase and take another path — that is technically DFS: go as deep as possible, and when you cannot go further, come back and take another path. DFS is inherently more suitable for the maze; BFS is not suitable — you can still use it, but it is not optimal. And for unknown depth in a large tree, iterative deepening is preferable.
Exam note: the intuition that a maze is a DFS problem and that IDS suits unknown-depth large trees is exactly the kind of reasoning to practice. The animations remain the recommended way to internalize how each algorithm explores — they are not exam questions themselves, but they are the foundation of these traditional AI techniques.
When to use IDS — and when not. Choose IDS when the state space is larger than memory and the solution depth is unknown — it is the preferred uninformed search in that situation, complete and memory-lean. Choose iterative lengthening for the wide-tree (high branch factor) case with costs. The honest limits: if the tree is deep AND wide (say depth 2000 with branching 1000), even IDS ends up exploring everything; it is better than plain DFS or BFS, not magic. And note that in a real graph with cycles, IDS must check for cycles along the current path — otherwise the depth limit is the only thing keeping it from looping.
Recap + bridge. IDS = DFS with a leash: run depth-limited DFS at limit 0, 1, 2, ... until the goal appears, buying BFS-like completeness and DFS-like memory. This closes the uninformed family. From here the lecture changes direction: every uninformed algorithm is slow because it searches blind, and the fix is a heuristic — the topic of the next section.
3.7 Heuristic Functions and Informed Search
3.7.1 What a Heuristic Is
Hook: Chess has more possible states than there are atoms in the observable universe — no search can visit even a fraction of them. To search a space like that, an agent needs something to guess which paths are promising. That guess has a name: a heuristic.
Informed search is more useful for large search spaces — a state space is the transition diagram we draw, and for something like chess it is far too big to draw at all; every move produces a different state. Informed search algorithms use the idea of heuristics, so the family is also called heuristic search. A heuristic function is a function used in informed search that finds the most promising path, cost, or solution. It takes the current state of the agent as its input and produces an estimation of how close the agent is to the goal:
It does not promise the best solution — the heuristic method might not always give the best solution, but it is guaranteed to find a good solution in reasonable time. Two practical notes: the heuristic function is not probabilistic — it is a deterministic function; you put values in, you get an answer. And in many cases — including in exams — you will be given the heuristic function, or even the promising path directly; do not worry about how it is derived.
Intuition + analogy. A heuristic is a guiding light: helpful, but never a guarantee of the best result. The professor's summary: "Heuristics is that extra information on a problem, which is more like a guiding light to us, which will help us to perform better — but is it the best? Not necessarily." The city-guide analogy makes the mapping explicit: a guide in a new city does not know exactly how long your trip will take, but every day they take passengers, and when you start a trip they tell you "about two hours it may take — but if traffic is more, or today is a weekend, maybe it'll take 1.5 hours on this route". That estimate is not the actual kilometer reading and not the exact outcome — it is extra knowledge layered on top of the map and nodes, coming from a person who is a domain expert in that city. The heuristic plays exactly this role in search: it points, it does not dictate. Where the analogy breaks: a city guide can apologize and be corrected on the spot, while the heuristics in this lecture are fixed before the algorithm runs.
Where the estimate comes from matters less than what it does: a node is selected for expansion based on an evaluation function that estimates the cost to the goal. The heuristic is the ingredient that turns a blind algorithm into an informed one.
3.7.2 Good versus Bad Heuristics
There are two aspects of any heuristic: a good one and a bad one. There are proofs and standard ways to decide which is which — admissibility and consistency — which are covered in the next topic. The intuition: before applying a heuristic to a problem, evaluate it fairly. The professor's analogy: before a career switch you ask three people for advice; if one of them gives you useless advice, you immediately see it and discard that heuristic and go with another. So you evaluate heuristics, decide if they are good or bad, and then apply them to the problem.
Assumptions and scope. A heuristic only earns its keep inside its own domain. A travel-time estimate built for rush-hour city traffic says nothing about a rural road network; a chess evaluation tuned for the middlegame misleads in the endgame. Heuristics are not guarantees: they can be wrong, they can be good or bad, and there are formal conditions (admissibility, consistency — next section) that tell you when a heuristic is safe to trust for optimal search. And because today's heuristics are fixed before the search runs, a bad one cannot correct itself mid-search.
3.7.3 Student Questions and Analogies
Q: Could you give a concrete analogy for a heuristic?
A: A city guide in trip planning. He has an estimate: every day he takes passengers, and when you start a trip he tells you "about two hours it may take — but if traffic is more, or today is a weekend, maybe it'll take 1.5 hours on this route." Does that mean the estimate is exactly what happens? No — but it guides you. It is extra information, coming from a person who is a domain expert in that city. It is not the actual kilometer alone; it is extra knowledge layered on the map and nodes.
Q: Is the heuristic always correct?
A: Not necessarily. It is just an intuition — nothing guarantees whatever it says is correct. There are only two categories: good heuristic and bad heuristic, and there are formal ways (admissibility, consistency) to tell which one you have.
Q: Why take advice at all if it can be wrong? Something is better than nothing?
A: Exactly — at least some guidance is good. In life you take advice from seniors, friends, or professors you trust because some guidance is better than having only your own way of doing things. That is what informed search means.
3.7.4 Where Heuristics Come From
For the whole of this session, every heuristic value is human-given: a domain expert supplies the estimate before the algorithm runs. The heuristic is not updated at runtime. But there is a whole class of learning heuristics techniques where the heuristic itself learns from patterns — that is part of this course's curriculum this semester, and a good amount of the next session is spent on how a heuristic can learn, how to create these functions, how to decide good versus bad, and specific use cases for heuristics (like databases and similar).
Recap + bridge. A heuristic is a deterministic, domain-expert-supplied estimate of the cost to the goal — a guiding light, not a promise. The uninformed family was blind; the heuristic is the extra information that makes search informed. Two informed algorithms use it in different ways: greedy best-first search trusts only the heuristic, and A* weighs it together with the actual cost spent so far — that is exactly the choice made in the next two sections.
Real-world: Google Maps relies heavily on heuristics of exactly this kind, though the real system is far more advanced (see the informed-search sections). The frontier of practice is learning heuristics: instead of paying a domain expert for every new domain, algorithms learn the heuristic function from patterns in the data — which is where the course goes next.
3.8 Greedy Best-First Search (GBFS)
3.8.1 Definition
Hook: You now have a heuristic — an expert's guess about how close each node is to the goal. What happens if the search trusts that guess and nothing else? You get greedy best-first search: fast, focused, and often wrong about the price.
Greedy best-first search (GBFS) is an informed search technique that takes heuristics very seriously — it works only on the heuristics. Whatever heuristic value is given, that alone drives the search; the actual path costs are ignored completely. The evaluation function is simply the heuristic itself:
where is the evaluation used to pick the next node, and is the heuristic value — the estimated cost from node to the goal (not an actual measured value, just the estimate someone gave us). GBFS expands the node with the smallest .
Purpose. GBFS answers "which node looks closest to the goal?" — it expands the frontier node with the smallest , on the grounds that the node that appears closest is likely to lead to a solution quickly.
Inputs and outputs. Input: the graph plus a heuristic value for every node. If the heuristic data is not available, GBFS is not the tool — it is an informed search and cannot fall back to actual costs. Output: a path to the goal that is usually found quickly but is not guaranteed to be cheap.
Reading the heuristic table correctly matters: every value means "from node to the goal". Bucharest has because it is the goal — if you are already in Bucharest, it takes 0 kilometers to reach Bucharest. Arad's 366 means "if you are in Arad, it will take about 366 kilometers (or whatever metric) to go to Bucharest." These numbers come from a domain expert — someone who knows the whole region and its intuitions and hands you this data.
3.8.2 Worked Example — Romania
Worked example: GBFS from Arad to Bucharest. We are on the Romania map: start at Arad, goal at Bucharest. Actual road costs (which GBFS will not look at): Arad → Sibiu = 140, Sibiu → Fagaras = 99, Fagaras → Bucharest = 211. Heuristic values: , , , , , , .
- At Arad (366). Neighbors: Zerind (374), Timisoara (329), Sibiu (253). Smallest heuristic: Sibiu (253). Note we never write down the actual edge costs — the 253 is not the Arad-to-Sibiu cost.
- Expand Sibiu (253). Neighbors: Fagaras (176), Rimnicu Vilcea (253), Oradea (380), Arad (366). Smallest: Fagaras (176).
- Expand Fagaras (176). Neighbors: Sibiu (253) and Bucharest (0). Smallest: Bucharest — we have reached the goal.
Path found: Arad → Sibiu → Fagaras → Bucharest. What did the search actually spend? From the graph: Arad → Sibiu = 140, Sibiu → Fagaras = 99, Fagaras → Bucharest = 211, total
Sense-check: the heuristic had promised 253 from Sibiu — an underestimate of the real remaining cost (99 + 211 = 310). Because GBFS believed only the heuristic, it got carried away and did not find the optimal route, which runs through Rimnicu Vilcea and Pitesti at a total of 418. The route GBFS found is 32 units more expensive than the best route — greedy looked good and turned out costly.
3.8.3 Worked Example — Five-Node Graph
Worked example: GBFS on a five-node graph. A small graph with nodes 1 through 5; start is node 1, goal is node 5. The actual edge costs (minutes) are: 1 → 2 = 100, 1 → 3 = 100, 1 → 4 = 100, 2 → 3 = 50, 2 → 5 = 125, 3 → 5 = 125, 4 → 5 = 50. (These are the edges the walkthrough uses: node 1's neighbors are 2, 3, 4, and node 3's neighbors are 4 and 5 — so node 3 also connects to node 4. The updated edge values 1 → 2 = 70 and 1 → 3 = 125 belong to the A* variant later in the lecture.) The heuristic values: , , , , . A domain expert who knows this floor plan — your house, your office, the mall, the exam center — gives us: "from 1, if you want to go to 5, it will take 60 minutes; from 2, 120 minutes; and so on."
- Expand node 1: neighbors 2 (h = 120), 3 (h = 30), 4 (h = 40). Smallest: node 3.
- Expand node 3: neighbors 4 (h = 40) and 5 (h = 0). Smallest: node 5 — the goal. Stop.
Path: 1 → 3 → 5. The actual cost: 1 → 3 = 100, 3 → 5 = 125, total
About the numbers the professor asked to track:
- Expanded nodes — we asked "where can you take me?" — were only 1 and 3; nodes 2 and 4 were generated but never expanded.
- Generated nodes — every node ever put in the queue — count six in total: the start node 1, then 2, 3, 4 from node 1, then 4 and 5 from node 3 (node 4 is generated twice).
- The max queue length at any point was three: initially just node 1; after expansion, 2, 3, 4; after expanding 3, nodes 4 and 5 remain.
Sense-check: the search stopped at the first goal node it reached — 1 → 3 → 5 at cost 225 — without ever expanding 2 or 4. Whether a cheaper route exists is irrelevant to GBFS: it never looks at the actual costs, so it cannot know.
3.8.4 Why GBFS Is Not Optimal
GBFS is not optimal. Two reasons are worth separating. First, it is greedy: a greedy algorithm takes what is best at the current moment without regard to future consequences. Greedy never promised the best possible way — it optimizes only for the current situation. Second — and this is the professor's deeper point — GBFS did not fully use the knowledge it had: the actual path costs were sitting right there in the problem, and it ignored them. It is the person who just believes others' advice and does not introspect: "You already know what is best for you. You're also taking advice. Why are you just believing on others' advices? Look at your data also. Think about yourself also."
Note the careful phrasing: GBFS did not take the wrong path — it took you to the goal — but its path cost was not optimal. In the five-node example it reached node 5 with cost 225, while the graph offers routes the search never priced: 1 → 2 → 5 = , 1 → 2 → 3 → 5 = , 1 → 3 → 5 (the route taken), and the routes through node 4 (1 → 3 → 4 → 5 and 1 → 2 → 3 → 4 → 5), each with its own cost. The lecture's point stands whichever route you price: the greedy search picked its path from the heuristic alone, so optimality was never even on the table.
In worst cases GBFS graph search is complete only on finite state spaces (on infinite spaces it can chase an ever-decreasing heuristic forever), and its worst-case time and space are — though with a good heuristic it typically explores far fewer nodes than that, in favorable cases dropping to .
3.8.5 Student Questions and Answers
Q: Arad to Sibiu is 253?
A: You have got this wrong — none of these values is a path cost between two cities. Arad's 366 means from Arad to Bucharest. And from Arad there are three ways: Sibiu, Timisoara, or Zerind — we did not write any path cost for those. The 253 says: if you go to Sibiu, Sibiu will take you in 253 units to Bucharest. All of these values are purely heuristics; GBFS relies only on these. Arad to Sibiu (the edge cost) was not considered at all. In short: heuristic values promise the remaining cost to the goal, never a path cost between two cities.
The same reading rule answers the next pair of questions about where heuristics come from and what happens to the start node's own value.
Q: Can the heuristic be considered a learned parameter of the machine?
A: You are on the right direction — this will not scale; you cannot have a domain expert in every place. There is a class of techniques called learning heuristics, where the heuristic itself learns from patterns, and it is part of this course (it has never been in the curriculum before this semester). We will spend a good amount of time on it next class. But so far, today, all of these values are human-given.
Q: Do we learn heuristics from experience? Is the heuristic updated on the fly?
A: Not in any of today's techniques. The heuristic is designed before the algorithm runs; you evaluate whether it is good or bad, and if it is promising you use it — it is not updated at runtime. Learning heuristics (where the algorithm itself creates its own heuristics) is exactly the next class's topic.
Q: Why wasn't the heuristic value calculated from the actual cost?
A: There are two things here. We are given two inputs: the actual cost and the estimates. If you use only the estimate, that is GBFS; if you use both, that is A*. Where itself comes from is a totally different question — a domain expert, your own experience, or a function model where you plug values in and get an answer. We will talk about how to create these s next class.
Q: What do we do with the value 60 at the start node?
A: Nothing, initially — we started at node 1 anyway. But if node 5 were not the goal, and some successor led back to node 1, then node 1 would be generated again, and at that point its heuristic (60) would matter for choosing whether to explore it.
Q: Is it mandatory to have heuristic values for all nodes? What if heuristic data is not available?
A: GBFS is an informed search — you need the heuristic values; considering actual cost instead is not an option in this technique. If the heuristic data is not available, GBFS is not the tool.
Now the questions that circle the real weakness — optimality — and what GBFS never looks at.
Q: If you add random exploration of neighbor nodes to the greedy move, will it be optimal?
A: Any greediness reduces the chance of optimality. To compensate, you add extra intuition — like exploring neighbor nodes and choosing the more promising one — and you can make it optimal. In general: if you know the exact problem, you can combine greedy with extra techniques and make it optimal for sure. But you cannot come up with an algorithm that is optimal for all use cases — that is the territory of NP-complete and NP-hard problems. If you tone the problem down to a well-understood case, you can target an exactly optimal algorithm — but you have solved a reduced set, not the generalized version.
Q: Suppose the cost of one step is minimum, but after following that path the other path costs are very large — won't this be infeasible?
A: That is exactly what we mean — we never claimed optimality is always best; the heuristic is guiding you, and guidance can sometimes mislead. This is why A* exists: it considers the actual cost along with the heuristic and is more cautious, so we do not end up in the situation you describe.
Q: What is the actual total cost of the Arad → Sibiu → Fagaras → Bucharest route? Is it 253 from Sibiu?
A: 253 is just the estimate. For the actual cost, go back to the graph: Arad to Sibiu is 140, Sibiu to Fagaras is 99, Fagaras to Bucharest is 211 — . Sibiu told us it would take us to Bucharest in 253, but did it really? The actual path costs alone are 99 plus 211 — over 300. We got carried away because we only believed its word. Domain expertise is a must, and pure supervision does not work here — which is why learning heuristics are coming.
Q: Why is GBFS not great? It reached the goal.
A: It reached the goal — it did not take you to the wrong place; the path cost was not optimal. The fundamental problem is that it did not fully use the knowledge it had. It only believed the heuristic and never looked at the actual costs sitting in the problem. He is that person who just believes on others' advices and not introspecting — you know what is best for you, so use your own data too.
Two questions connect GBFS to its cousins — Dijkstra's algorithm and the informed family.
Q: Is UCS the same as Dijkstra's? And A* versus Dijkstra?
A: UCS and Dijkstra's are the same — single-source shortest path. A* follows the same algorithmic intuition, but with a twist: what A* adds is a heuristic, whereas in Dijkstra what you add is the actual cost you see in the graph (how far have I come). Dijkstra is not an informed algorithm — it has no extra information like a heuristic. The right statement: UCS and Dijkstra are the same; A* is the informed variant.
Q: Does Google Maps use this?
A: Google Maps is a very, very advanced algorithm because of the environment — think back to the environment types from the last class. In the real world where Google Maps operates, what is the environment? Fully observable? Stochastic? Episodic, sequential, dynamic — it is dynamic. Suddenly there is an accident, someone reports it, and the route changes. Users suggest things: "there is a roadblock here" — all of that is taken into consideration. Those are heuristics again, updated live. So Google Maps uses sophisticated things, but it all boils down to some of these fundamentals. In other words: Google Maps layers live heuristics over a dynamic environment — it is not plain A* running on a static graph.
And the vocabulary question that trips up many students — it matters for exam traces.
Q: What do "expanded" and "generated" mean?
A: Expanding a node means actually asking the question "where all can he take me?" — when we were at the root node we asked it and learned we can go to 2, 3, or 4. The new nodes produced by that question are the generated nodes, and they go into the queue. In the five-node example only 1 and 3 were expanded — we never asked node 2 or node 4 where they could take us. Node 5 was not expanded because it is the goal; we reached it and stopped.
Exam note: a probable question pattern is: given a graph, actual costs, heuristic values, start and goal, trace GBFS — state which nodes were expanded, which were generated, the queue behavior (max queue length), the path found, and its actual cost. The value of the start node's own heuristic is not used unless the search returns to it.
Recap + bridge. GBFS trusts the heuristic alone: , expand the smallest. It reaches the goal fast, but ignores the actual costs it has, so the path can be expensive — the person who believes every piece of advice and never introspects. The fix is to use both inputs — and that is precisely what A* does next: .
3.9 A* Search
3.9.1 Definition and Evaluation Function
Hook: GBFS trusted the expert's guess and got carried away; UCS trusted only the costs and explored too much. What if the search weighed both — what you have already paid and what the expert promises? That is A*, one of the most used algorithms in pathfinding.
A* search is one of the best and most popular techniques in pathfinding and graph traversal; a lot of games and web-based maps use it to find the shortest path efficiently. It is essentially a best-first search algorithm, an informed search technique that works with heuristic values. A* maintains a tree of paths originating at the start node, extends those paths one edge at a time, and continues until its termination criteria are satisfied. The core idea: avoid expanding paths that are already expensive.
A* extends the path that minimizes the evaluation function
where:
- is the cost so far to reach node from the start node — the actual cost incurred, summed along the edges. It is 0 for the start node, because we have not come from anywhere.
- is the heuristic value — the estimated cost from to the goal. It is 0 for the goal node, because the estimated cost from the goal to the goal is 0.
- is the estimated total cost of the path from the start to the goal passing through — the two quantities added.
Compare with GBFS, where directly: no path cost considered, whatever the intuition says, take that. A* says: add the heuristic to the actual cost incurred so far. If both together are already expensive, the path is misleading me — so do not take it. This is the more cautious, better informed algorithm.
3.9.2 Worked Example — Five-Node Graph
Worked example: A* on the five-node graph. Same five-node layout; the version shown here uses updated values: edges 1 → 2 = 70, 1 → 3 = 125, 1 → 4 = 100, 4 → 5 = 50. Heuristics: , , , , . Start 1, goal 5.
- Expand node 1: successors 2, 3, 4. Compute for each — actual cost from 1 plus heuristic of the successor:
The smallest is 140 (node 4). Nodes 2 and 3 are "already betraying me": to come till that node, and then its heuristic — put together they are less promising.
- Expand node 4: successor 5. Apply the formula afresh to the new node:
The cost so far: 1 → 4 = 100, then 4 → 5 = 50; the heuristic of the goal is 0. Total 150. Node 5 is the goal — stop.
Path: 1 → 4 → 5, total cost 150. Expanded: 1 and 4. Generated: 1, 2, 3, 4, 5 (nodes 2 and 3 remain in the queue, never expanded, because the goal was reached).
Sense-check: with the heuristic removed, this would be Dijkstra's algorithm — it would have expanded nodes 2 and 3 as well before declaring 5 the answer. The heuristic let A* skip them: 150 is exactly the cost of the cheapest route, and the search never looked at a node with .
A common student slip — the professor flags it as "very, very important": do not carry the 140 forward to node 5. The 140 was the -value of node 4. Once we expand node 4 and generate node 5, we compute from scratch with its own and : the cost incurred so far (100 + 50 = 150) plus the heuristic of node 5 (0). The re-explanation walkthrough: "What is the cost to come till here? That is 1 to 4 plus 4 to 5. 1 to 4 is this 100, and 4 to 5 is this 50. 100 plus 50. What is the heuristic value of 5? It is 0, because I am already in the goal. So 100 + 50 + 0 = 150. You are done."
Q: Still not clear how 150 came. Can you do it once more?
A: A* uses both the actual data and the heuristic data. I am at node 1, the start. I expand it — I can go from 1 to 2, 1 to 3, or 1 to 4 (the arrows show 1 → 5 does not exist). For each successor I apply . : the cost incurred to come from 1 to 2 is 70, and node 2's heuristic — what 2 promises me — is 120, so 70 + 120 = 190. : 1 → 3 costs 125, heuristic 70, so 195. : 100 + 40 = 140. Among the three, 140 is most promising — these two guys are already betraying me. From 4 I can only go to 5. Now, what is ? Not 140 — do not carry the 140 forward. The cost taken to reach node 5 is 1 → 4 plus 4 → 5: 100 + 50. The heuristic of 5 is 0, because I am already at the goal. So . Done. The rule in one line: add the cost taken to reach the new node plus its heuristic — never the previous node's .
Q: Can we try the same graph with , like in the GBFS example?
A: Yes — you can always change the values and try. Then , which is still larger than 140, so node 4 is still chosen. If, on the other hand, that value were smaller, the search would explore node 3 instead.
3.9.3 Worked Example — Romania
Worked example: A* from Arad to Bucharest (full trace). The full Romania map with actual road costs and the heuristic table : Arad 366, Sibiu 253, Timisoara 329, Zerind 374, Fagaras 176, Rimnicu Vilcea 193, Oradea 380, Pitesti 100, Craiova 160, Bucharest 0. (The value 193 for Rimnicu Vilcea is confirmed by the leaf value 413 = 220 + 193; the reference straight-line-distance table also lists 193.) Start Arad, goal Bucharest.
- Start at Arad. (no cost incurred to start here), , so . Expand Arad: successors Zerind, Sibiu, Timisoara. For each, = actual cost from Arad, = that node's heuristic:
Sibiu (393) is most promising. Expand it.
- Expand Sibiu (140 so far). Successors Fagaras, Rimnicu Vilcea, Oradea, and back to Arad:
Leaves now: Fagaras 415, Rimnicu 413, Oradea 671, Arad 646, plus Timisoara 447 and Zerind 449. Smallest: Rimnicu Vilcea (413). Expand it.
- Expand Rimnicu Vilcea (220 so far). Successors Pitesti, Craiova, and back to Sibiu:
Now the key step. New students look at the three new values, see 417, and expand Pitesti right away. Do not. The queue still holds all leaves: Fagaras 415, Oradea 671, Arad 646, Timisoara 447, Zerind 449, Pitesti 417, Craiova 526, Sibiu 553. The smallest of all leaves is Fagaras at 415 — smaller than Pitesti at 417. So expand Fagaras.
- Expand Fagaras (239 so far). Successors Sibiu and Bucharest:
We have expanded Fagaras and generated Bucharest — we have not reached Bucharest; the goal is only claimed when it is expanded. Leaves: Pitesti 417 is now the smallest. Expand Pitesti.
- Expand Pitesti (317 so far). Successors Bucharest, Craiova, and back to Rimnicu Vilcea:
Among all leaves the smallest is Bucharest at 418 — note the earlier Bucharest (via Fagaras) was 450, this one is 418. It is the goal node, so we stop.
The A* path: Arad → Sibiu → Rimnicu Vilcea → Pitesti → Bucharest, total cost 418, which is the best path in the real graph. The professor invites checking the graph for other routes to confirm none is cheaper. The lesson of step 3 is emphasized: always compare all the leaf nodes in the queue, not just the ones just generated — that is why Fagaras (415) is expanded before Pitesti (417).
Sense-check: every node expanded had , and every leaf left in the queue has — so no unexpanded route can beat 418, and the first goal expanded is the optimal one.
Q: Why do we expand Fagaras instead of Pitesti at that step?
A: Compare all the leaf nodes in the queue, not only the ones just generated. At that moment the leaves are Fagaras 415, Pitesti 417, Craiova 526, Sibiu 553, Oradea 671, Arad 646, Timisoara 447, and Zerind 449. The smallest is Fagaras at 415, so it comes first. Students often expand Pitesti at this step because 417 is the smallest of the three new values — that is the mistake to avoid.
3.9.4 Student Questions and Answers
Q: If we rely on the actual values anyway, why do we need the heuristic values at all?
A: The heuristic is what helps us choose the most promising path. Suppose it were not there: then this is just Dijkstra's algorithm — single-source shortest path with 1 as source and 5 as goal — and you would have expanded nodes 2 and 3 as well, exploring everything before finding the answer. The heuristic told us among these successors which is the most promising path, and we took that path. That is the value of the estimate.
Q: Can we have negative edges in A*?
A: You can have negative edges, but as long as the two conditions are satisfied — we see them next — A* stays optimal; if they are not satisfied, it is not optimal.
Q: Is A* optimal?
A: A* is optimal, provided the heuristic satisfies some conditions. That is exactly the next topic — admissibility and consistency. Between GBFS and A*, which is better should already be clear.
Q: Is this the only version of A*?
A: This is the generic, classic version. Many variants of A* are possible — a couple of them are in your textbook, others exist in research papers. We stick to the classic version in this course; do not worry about the extra variants.
Q: Given a problem with the graph, , , source, and goal, should we be able to trace the whole search?
A: Yes — with a graph, heuristic values, path costs, source and goal given, you should be able to produce the state-space tracing: which nodes get expanded in what order, the path, and the cost. A lot of thumbs up in the class — but remember the dependency: if the heuristic is not close to the actual, things get messed up. Evaluating good versus bad heuristics is our job, and that is where we go next.
Exam note: a likely exam task is exactly that trace: given graph, , , source, and goal, produce the state-space trace with the expanded nodes in order, the path, and its cost. When multiple nodes tie for the smallest , follow lexicographical (alphabetical) ordering — that is the convention to use in exams.
Recap + bridge. A* balances both inputs: , expand the smallest, claim the goal only at expansion, and always compare every leaf in the queue. It found 418 in Romania where GBFS found 450. But "A* is optimal" has a condition attached — the heuristic must be admissible and consistent. That condition is the final topic: it decides when A*'s guarantee actually holds.
3.10 Admissibility and Consistency
3.10.1 Admissibility
Hook: A* is optimal — but only under conditions. A star is a careful searcher, yet its carefulness is only as good as the heuristic that steers it. The two conditions that decide optimality are admissibility and consistency, and both are simple inequalities you can check by hand on every node.
A* is optimal when the heuristic satisfies two conditions: admissibility and consistency.
A heuristic is admissible if it never overestimates the actual cost to reach the goal:
where is the heuristic value you were given (as in all the problems so far), and is the true cost from node to the goal — the real, actual cost found in the graph. Students sometimes want to put here; that is wrong. is the cost taken from the initial node to arrive at node . is from node to the goal — a different quantity entirely.
Worked example: admissibility check on Pitesti. At the step where the current node is Pitesti, (Arad → Sibiu → Rimnicu Vilcea → Pitesti: 140 + 80 + 97). The true cost is the actual Pitesti → Bucharest road cost, which is 101. Our heuristic said .
Check the condition: is
Yes — 100 is less than 101, so this heuristic is admissible; it did not overestimate. The heuristic may underestimate the cost — it is optimistic — but it must never exaggerate it.
Sense-check: a heuristic that said 200 would fail the check (200 > 101), and A* could then reject the real cheapest route as "too expensive", breaking optimality. The Pitesti value of 100 is on the safe side: close to the truth and still below it.
Real-world: straight-line distance is admissible for route planning, because the actual road cost between two places cannot be shorter than the straight-line distance between them. No road is a perfectly straight line — they all bend, so the true driving distance is at least the bird's-eye distance. That makes straight-line distance a natural admissible heuristic for maps.
3.10.2 Consistency
How close the heuristic is to the true value matters, and that is what the second condition, consistency (also called monotonicity), captures. A heuristic is consistent if, for every node and every successor of :
where is the actual cost of the step from to , and , are the heuristic values of the two nodes. The plain-language meaning: the estimated cost should not suddenly drop by more than the actual step cost. As we move towards the goal, the heuristic should reduce gradually — the estimate decreases along the path, but no faster than the real step cost justifies.
Why the inequality is a triangle inequality. Picture a triangle with vertices , , and the goal. The direct edge from to the goal is one side — its length is bounded below by the estimate . The path is the other two sides — cost plus the estimate . Consistency says a side of a triangle cannot be longer than the sum of the other two sides: the direct estimate cannot exceed the roundabout route . Straight-line distance satisfies this on any map, because a straight line is always shorter than any broken line — so the straight-line heuristic is consistent as well as admissible. Every consistent heuristic is admissible, but not every admissible heuristic is consistent.
Example of the intuition: and — the estimate is close to the truth. A value of 10 would also satisfy admissibility (10 < 101, no overestimate), but 10 is not close to the actual 101 — a weak guide. Closeness is what distinguishes a good heuristic from a merely admissible one.
3.10.3 Why Consistency Matters
If a heuristic is consistent, -values do not decrease along the path. This means: once A* expands a node, the best path to that node has already been formed — there is no danger that a later, cheaper route to the same node appears. If this property is not satisfied, "we will go for a toss": the search can re-find nodes more cheaply, and the optimality guarantee breaks down. Both conditions — admissibility and consistency — must hold for all nodes; then A* is optimal and you will definitely get the correct answer. Otherwise A* is not optimal.
The reasoning in one breath: moving from to changes from to . The cancels, and the -value is non-decreasing exactly when — which is precisely consistency. So with a consistent heuristic, A* expands nodes in order of non-decreasing ; the first time it pops a node, that node has already been reached by its cheapest possible path, and the first goal popped is the cheapest goal.
3.10.4 Student Questions
Q: Is the same as ?
A: No — and students often make this mistake. is the cost that took us from the initial node to node . is the actual, true cost from node to the goal — you read it off the graph, from forward. In the Pitesti step: (what we already spent), while (the remaining road cost to Bucharest). The heuristic , so it is admissible.
Q: Underestimation is fine — could the heuristic be 50, or even 10? That could change the route.
A: Yes, 10 is also admissible — it is less than the true cost, it satisfies the condition, and it could indeed change the route that A* picks. But admissibility alone is only the first condition. The question "how close is 10 to the actual 101?" is answered by the second condition, consistency. 100 is close to 101; 10 is not.
Q: So if the heuristic is not close to the actual, the search is messed up?
A: Exactly — that is why evaluating good versus bad heuristics is our job. But given a reasonable heuristic, A* does the job, and you should be able to trace it.
Q: Why does consistency matter so much — what does it buy us?
A: If a heuristic is consistent, -values never decrease along the path. That means once A* expands a node, the best path to that node has already been formed — no later, cheaper route to the same node can show up and force a redo. If consistency fails, the search can re-find nodes more cheaply, and the optimality guarantee breaks down — we will go for a toss.
3.10.5 Exercises for the Next Class
Two exercises were set. First, planning and problem formulation — three problems, and for each you should formulate the five components (initial state, goal state, actions, transitions, path cost) and, as extra practice, do the PEAS and environment definition as well: planning a trip with a delivery drone; solving a maze; scheduling patient appointments in a clinic. Second, an A* trace: a graph is given with data — the start, the goal, actual costs, and heuristic values , , and so on — run A* on it and report the search. A third task will be done together next class: for each node of a given graph (with node 3 as the goal), check whether the given heuristic is admissible, and then check consistency — the class already agrees on the admissibility answers, and the consistency check via the formula will be worked through together.
Exam note: expect to be asked whether a given heuristic is admissible and/or consistent, and to explain what each condition guarantees about A*'s optimality. The two inequalities are the whole check: per node for admissibility; for every edge for consistency.
Recap + bridge. Admissibility keeps the heuristic optimistic (); consistency keeps it from dropping too fast (). Together they make -values non-decreasing, so the first goal A* expands is the cheapest — that is when A* is optimal. This closes the lecture's arc: from the five-component formulation, through the uninformed family, to heuristics, GBFS, A*, and the conditions that make A* trustworthy. Next class turns to the heuristics themselves — how they are created, and how they can be learned.
Exam Guidance Summary
- Mid-semester exam talk: the professor will discuss the mid-sem exam in the 8th class and will upload a sample paper then; the same happens before the final exam. The ACI exam usually falls in the second week of the exam schedule, so there is preparation time after the discussion.
- Sample papers: the course has changed a lot — many topics were removed and new ones added — so some past papers may not be relevant. The advice is explicit: do not get bogged down by sample papers and exam preparation; there is no correlation between solving past papers and performing better, and it can do more harm than good. Attend all classes, explore the topics, and you will fare well; the quiz, the assignments, and the final exam are other avenues.
- Probable question types so far (learning outcomes):
- PEAS specification for a given situation; judging an environment (e.g., chess) across its different aspects.
- Choosing the best-suited agent architecture (reflex vs goal-based vs utility-based, etc.).
- Formulating a problem with the five definitions: initial state, actions, transition, goal, path cost.
- Tracing uninformed searches — BFS, DFS, UCS, iterative deepening — and knowing the intuition for when each fits (e.g., maze → DFS; unknown depth, large tree → iterative deepening). The animations are not exam questions, but they form the basis of the techniques.
- Tracing GBFS given a graph, heuristic values, start and goal: expanded nodes, generated nodes, queue behavior (max queue length), the path, and its actual cost.
- Tracing A* given the graph, , , source, and goal: produce the state-space trace, the path, and the cost. When multiple shortest paths tie, use lexicographical (alphabetical) ordering in exams.
- Admissibility and consistency of a heuristic, and what they guarantee about A* optimality: for admissibility; for consistency, checked per node and per edge.
- Study resources: the uninformed-search animations (play with your own inputs); the data-structures material on the course page, only if you lack a CS background (queues, stacks); the lab activity where BFS and DFS are implemented — the recording and the Python program are available if you want to see the algorithms in code.
Key Industry Applications
- BFS: finding a path in a graph, finding many solutions, and graph-theory problems such as bipartition — checking whether a network can be split into two groups with no edges inside a group, useful in scheduling and matching problems.
- DFS: quickly checking connectedness in a graph — e.g., are two people connected in a social network (walk from one, go deep, backtrack until you either meet the other person or exhaust the paths) — and topological sort, which DFS always produces in the correct ordering, a staple of build systems and task scheduling (a task is listed only after its prerequisites).
- UCS: cheapest-first route planning with real measured costs — kilometers, miles, or fares from actual empirical data. Under its other name, Dijkstra's algorithm, it is the workhorse of network routing: computer networks, logistics, and shortest-path services all run uniform-cost ideas at scale.
- A*: pathfinding and graph traversal in a lot of games and web-based maps; it finds the shortest path efficiently by balancing cost so far with the heuristic. Video-game enemy AI, GPS navigation, and robotics motion planning are the classic A* consumers.
- Google Maps (with a warning): it does not use just A* — it is far more advanced because its environment is dynamic: accidents get reported, routes change, users report roadblocks, and those inputs act as heuristics that are updated live. It uses sophisticated machinery, but it all boils down to these fundamentals.
- Heuristics in practice: domain experts supply the estimates (like a city guide's travel-time estimate); heuristics must be evaluated (admissibility, consistency) before use; and the frontier of practice is learning heuristics — algorithms that learn their own heuristics from patterns, covered later in the course.
ACI Lecture 3 notes · Uninformed and Informed Search
Sections Breakdown
The five components of a search problem, worked formulations (road trip, 8-puzzle), and the probable question types.
The two families of search, the comparison table, and why informed search uses a heuristic.
Level-by-level search with a FIFO queue, a queue trace, the branching-factor problem, and applications.
Deep-dive search with a stack, backtracking, the depth problem, and applications.
Cheapest-first search, the sorted-frontier rules, the Romania worked example, and complexity.
Depth-limited DFS with growing limits, iterative lengthening, and choosing a search algorithm.
What a heuristic is, the guiding-light analogy, good versus bad heuristics, and where they come from.
Search driven only by the heuristic, two worked examples, and why GBFS is not optimal.
The evaluation function f(n) = g(n) + h(n), worked traces on a five-node graph and Romania, and exam trace rules.
The two optimality conditions for A*, their triangle-inequality intuition, and the next-class exercises.
The professor's exam talk, sample-paper advice, probable question types, and study resources.
Where each search technique is used: bipartition, connectedness, topological sort, routing, games, and Google Maps.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Search Problem Formulation Recap
Must-know: Whatever problem is given, you must be able to write the five components: initial state, goal test, possible actions, transition model, and path cost; plus PEAS and environment judgement for a situation.
⚠️ Top pitfall: Confusing the goal test (a yes/no check) with the goal state (a specific destination), and forgetting that path costs are assumed positive and additive.
Self-check: For the 8-puzzle, what are the five components of the formulation?
Connects to: 3.2.
Uninformed versus Informed Search
Must-know: Uninformed search uses only the given problem; informed search adds a heuristic from a domain expert. Completeness is per-algorithm, not per-family.
⚠️ Top pitfall: Calling uninformed search random — it is systematic (queue for BFS, stack for DFS) but information-poor.
Self-check: Why is informed search usually more efficient than uninformed search?
Connects to: 3.7.
Breadth-First Search (BFS)
Must-know: BFS covers one level at a time with a FIFO queue; high branch factor means slow progress toward depth and wasted space/time.
⚠️ Top pitfall: Forgetting that BFS is optimal only when all action costs are equal; with differing costs, shallowest is not cheapest.
Self-check: Why does a node with 2000 children hurt BFS even when the goal is shallow?
Connects to: 3.4, 3.5.
Depth-First Search (DFS)
Must-know: DFS goes as deep as possible with a stack and backtracks at dead ends; its weakness is the depth problem (skewed trees), not the branch problem.
⚠️ Top pitfall: Expecting DFS to be complete or cost-optimal; it returns the first solution found and can loop forever on cyclic spaces.
Self-check: Why does DFS use far less memory than BFS?
Connects to: 3.3, 3.6.
Uniform Cost Search (UCS)
Must-know: UCS expands the node with the lowest g(n), keeps the frontier sorted, and only claims the goal at expansion; the first expanded goal is optimal.
⚠️ Top pitfall: Testing the goal during generation instead of expansion — this returns the suboptimal 310 route instead of the optimal 278 route.
Self-check: In the Romania example, why did UCS ignore Bucharest when Fagaras generated it at cost 310?
Connects to: 3.3, 3.8, 3.9.
Iterative Deepening Search
Must-know: IDS applies DFS iteratively with growing depth limits, avoiding DFS's deep-loop worst case while keeping memory small; iterative lengthening fixes BFS's wide-branch problem.
⚠️ Top pitfall: Thinking every iteration restarts from the root; in practice the search continues from the frontier of the previous iteration.
Self-check: Why does IDS use about the same time as BFS but far less memory?
Connects to: 3.3, 3.4.
Heuristic Functions and Informed Search
Must-know: A heuristic is a deterministic estimate of the remaining cost to the goal; it guides the search but never guarantees the best solution, and it must be evaluated (admissibility, consistency) before use.
⚠️ Top pitfall: Treating the heuristic as a promise or as a probability — it is an intuition that can be good or bad.
Self-check: Why is a city guide's travel estimate a good analogy for a heuristic?
Connects to: 3.2, 3.8, 3.10.
Greedy Best-First Search (GBFS)
Must-know: GBFS expands the node with the smallest h(n), uses no actual costs, is fast but not optimal; traces must report expanded nodes, generated nodes, max queue length, path, and actual cost.
⚠️ Top pitfall: Misreading heuristic values as path costs between cities — 253 is Sibiu-to-Bucharest estimate, not the Arad-to-Sibiu road cost; also confusing expanded (asked where it can go) with generated (new successors added to queue).
Self-check: Why did GBFS return 1-3-5 at 225 without expanding nodes 2 and 4?
Connects to: 3.5, 3.9.
A* Search
Must-know: A* expands the node with smallest f(n) = g(n) + h(n); never carry a previous node's f forward; compare all leaf nodes in the queue; the first goal expanded is optimal when the heuristic is admissible and consistent.
⚠️ Top pitfall: Carrying the previous node's f-value forward (140 into f(5)) and expanding a new node without comparing all leaves (Pitesti 417 before Fagaras 415).
Self-check: In the Romania trace, why is Fagaras (415) expanded before Pitesti (417)?
Connects to: 3.5, 3.8, 3.10.
Admissibility and Consistency
Must-know: Admissibility: h(n) <= h*(n) per node — the heuristic never overestimates. Consistency: h(n) <= c(n,n') + h(n') per edge — f-values never decrease, so the first goal expanded is optimal.
⚠️ Top pitfall: Putting g(n) in place of h*(n) — g(n) is the cost already spent from the start; h*(n) is the true remaining cost to the goal.
Self-check: Why is h(Pitesti) = 100 admissible when the true Pitesti-to-Bucharest cost is 101?
Connects to: 3.9.
Exam Guidance Summary
Must-know: The examinable skills are: PEAS + environment judgement, agent architecture choice, five-component formulation, uninformed-search traces and intuitions, GBFS traces, A* traces with lexicographical tie-breaking, and admissibility/consistency checks.
⚠️ Top pitfall: Over-studying sample papers — the professor states there is no correlation and it can do more harm than good.
Self-check: What convention should be used when multiple A* paths tie?
Connects to: 3.1, 3.8, 3.9, 3.10.
Key Industry Applications
Must-know: Each search technique maps to a named application: BFS-bipartition, DFS-connectedness/topological sort, UCS-cheapest routing (Dijkstra), A*-games and maps, Google Maps-live heuristics over a dynamic environment.
⚠️ Top pitfall: Claiming Google Maps is simply A* — it layers live user-report heuristics over a dynamic environment.
Self-check: Which search is best for checking whether two people are connected in a social network, and why?
Connects to: 3.3, 3.4, 3.5, 3.9.
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.