In AI, a search algorithm looks for a sequence of actions that leads from a starting state to a goal. The difference between the two families is one thing: uninformed (blind) search knows only the problem definition, so it explores states in a fixed order; informed (heuristic) search also has a heuristic function that estimates how far each state is from the goal, and uses that estimate to decide what to explore next. Everything else on this page, from speed to optimality, follows from that one difference.
What a search problem looks like
Both families work on the same problem definition:
- States and an initial state (for example, the starting city or the scrambled 8-puzzle board).
- Actions available in each state, and a transition model that says which state each action leads to.
- A goal test (is this the destination? is the board solved?).
- A path cost, usually the sum of step costs such as kilometres or moves.
Complexity is described with a few standard symbols: b is the branching factor (how many successors a state has), d is the depth of the shallowest goal, m is the maximum depth of the search space, and C* is the cost of the optimal solution.
Uninformed (blind) search
Uninformed search can tell a goal state from a non-goal state, but it cannot tell whether one non-goal state is "closer" than another. "Blind" does not mean random: each strategy expands nodes in a strict, systematic order.
- Breadth-first search (BFS) expands the shallowest node first using a FIFO queue. It finds the path with the fewest steps. A full walk-through is in BFS and DFS in AI.
- Uniform-cost search (UCS) expands the node with the lowest path cost
g(n)using a priority queue. It is Dijkstra's algorithm applied to search, and it finds the cheapest path when step costs differ. - Depth-first search (DFS) expands the deepest node first using a stack. It needs very little memory but can follow a long or infinite branch and miss a nearby goal.
- Depth-limited search is DFS with a cut-off depth
l; it fails if the goal lies deeper thanl. - Iterative deepening DFS (IDDFS) runs depth-limited search with
l = 0, 1, 2, …. It combines the low memory of DFS with the completeness of BFS. - Bidirectional search searches forward from the start and backward from the goal at the same time and stops when the two frontiers meet.
Informed (heuristic) search
Informed search adds a heuristic function h(n): an estimate of the cheapest cost from node n to a goal. On a road map, a common heuristic is the straight-line distance to the destination. The heuristic does not have to be exact; it only has to be cheap to compute and good enough to rank nodes.
- Greedy best-first search expands the node with the smallest
h(n), the one that looks closest to the goal. It is often fast but ignores the cost already paid, so it can return a poor path. See best-first search for more detail. - A* search expands the node with the smallest
f(n) = g(n) + h(n), the cost so far plus the estimated cost to go. With a suitable heuristic it finds the optimal path while exploring fewer nodes than UCS. The A* algorithm guide covers it step by step. - IDA* and recursive best-first search are memory-saving variants of A* that use a cost threshold instead of keeping every node in memory.
- Local methods such as hill climbing also use a heuristic, but they keep only the current state rather than a search tree; hill climbing and other search strategies are covered separately.
What makes a heuristic good
A heuristic function maps a state to a number. Two properties matter for A*:
- Admissible:
h(n)never overestimates the true cost to the goal, that ish(n) ≤ h*(n)for every node. Straight-line distance is admissible for road travel because no road is shorter than a straight line. - Consistent (monotone): for every node
nand successorn'reached with step costc(n, n'),h(n) ≤ c(n, n') + h(n'). Every consistent heuristic is admissible. With a consistent heuristic, A* graph search never has to re-open a node it has already expanded.
The 8-puzzle shows two classic heuristics. h1 counts tiles that are out of place; h2 adds up how many rows and columns each tile is from its goal square (Manhattan distance). Both are admissible, because every misplaced tile needs at least one move and at least its Manhattan distance in moves.
start = (7, 2, 4,
5, 0, 6,
8, 3, 1)
goal = (0, 1, 2,
3, 4, 5,
6, 7, 8)
def misplaced(state):
return sum(1 for s, g in zip(state, goal) if s != 0 and s != g)
def manhattan(state):
total = 0
for i, tile in enumerate(state):
if tile == 0:
continue
j = goal.index(tile)
total += abs(i // 3 - j // 3) + abs(i % 3 - j % 3)
return total
print("h1 misplaced tiles:", misplaced(start))
print("h2 Manhattan distance:", manhattan(start))
Output:
h1 misplaced tiles: 8
h2 Manhattan distance: 18
For every state h2 ≥ h1, so h2 dominates h1: it is a tighter estimate, and A* using it expands fewer nodes. A heuristic that is closer to the true cost, while still admissible, is almost always the better choice.
Informed vs uninformed search: comparison table
| Property | Uninformed (blind) search | Informed (heuristic) search |
|---|---|---|
| Knowledge used | Only the problem definition: states, actions, goal test, step costs | Problem definition plus a heuristic estimate h(n) of the cost to the goal |
| Order of expansion | Fixed by the strategy: depth, level or path cost | By an evaluation function such as h(n) or g(n) + h(n) |
| Other name | Blind search, brute-force search | Heuristic search |
| Examples | BFS, DFS, UCS, depth-limited, IDDFS, bidirectional | Greedy best-first, A*, IDA*, RBFS, beam search |
| Nodes explored | Usually more, because nothing points towards the goal | Usually fewer, if the heuristic is informative |
| Cost per node | Low: no extra computation | Includes computing h(n), which can be expensive |
| Optimality | BFS (equal step costs), UCS and IDDFS (equal step costs) are optimal; DFS is not | A* is optimal with an admissible heuristic (consistent for graph search); greedy is not |
| Completeness | BFS, UCS, IDDFS complete under standard conditions; DFS not in infinite spaces | A* complete with finite branching and positive step costs; greedy can get stuck in loops without a visited set |
| Needs domain knowledge? | No, it works on any problem that can be defined | Yes, someone has to design a heuristic for the problem |
Completeness, optimality and complexity of each algorithm
These are the standard results from Russell and Norvig's Artificial Intelligence: A Modern Approach, the textbook most university syllabi follow. ε is the smallest step cost and l the depth limit.
| Algorithm | Type | Complete? | Optimal? | Time | Space |
|---|---|---|---|---|---|
| BFS | Uninformed | Yes (finite b) | Yes, if all step costs are equal | O(bd) | O(bd) |
| Uniform-cost | Uninformed | Yes, if step costs ≥ ε > 0 | Yes | O(b1+⌊C*/ε⌋) | O(b1+⌊C*/ε⌋) |
| DFS | Uninformed | No (yes in finite spaces with cycle checking) | No | O(bm) | O(bm) |
| Depth-limited | Uninformed | No, fails if l < d | No | O(bl) | O(bl) |
| Iterative deepening | Uninformed | Yes | Yes, if all step costs are equal | O(bd) | O(bd) |
| Bidirectional (BFS both ways) | Uninformed | Yes | Yes, if all step costs are equal | O(bd/2) | O(bd/2) |
| Greedy best-first | Informed | No in general (yes in finite spaces with a visited set) | No | O(bm) worst case | O(bm) worst case |
| A* | Informed | Yes (finite b, step costs ≥ ε) | Yes, with an admissible / consistent h | Exponential in the worst case; depends on h | Keeps all generated nodes |
A good heuristic does not change A*'s worst-case bound, but in practice it cuts the number of expanded nodes sharply. Memory, not time, is usually what limits A* on large problems, which is why IDA* exists.
Worked example: the same graph, four algorithms
The graph below has a start S and goal G. Edges are one-way with the costs shown. The heuristic values are estimates of the remaining cost to G; they are admissible and consistent.
| Edge | Cost | Edge | Cost |
|---|---|---|---|
| S → A | 1 | B → C | 2 |
| S → B | 4 | C → G | 3 |
| S → E | 1 | E → F | 1 |
| A → B | 2 | F → H | 2 |
| A → C | 5 | H → G | 10 |
| A → G | 12 | h: S=6, A=5, B=4, C=3, E=10, F=10, H=9, G=0 | |
from collections import deque
import heapq
# Weighted graph: node -> {neighbour: step cost}
graph = {
"S": {"A": 1, "B": 4, "E": 1},
"A": {"B": 2, "C": 5, "G": 12},
"B": {"C": 2},
"C": {"G": 3},
"E": {"F": 1},
"F": {"H": 2},
"H": {"G": 10},
"G": {},
}
# Heuristic: estimated cost from each node to G (admissible and consistent)
h = {"S": 6, "A": 5, "B": 4, "C": 3, "E": 10, "F": 10, "H": 9, "G": 0}
def path_cost(path):
return sum(graph[a][b] for a, b in zip(path, path[1:]))
def bfs(start, goal):
frontier = deque([[start]])
reached = {start}
expanded = []
while frontier:
path = frontier.popleft()
node = path[-1]
expanded.append(node)
if node == goal:
return path, expanded
for nb in graph[node]:
if nb not in reached:
reached.add(nb)
frontier.append(path + [nb])
return None, expanded
def best_first(start, goal, priority):
"""Generic best-first search; priority(g, node) decides the order."""
frontier = [(priority(0, start), 0, [start])]
best_g = {start: 0}
expanded = []
while frontier:
_, g, path = heapq.heappop(frontier)
node = path[-1]
if g > best_g.get(node, float("inf")):
continue # stale queue entry
expanded.append(node)
if node == goal:
return path, expanded
for nb, cost in graph[node].items():
g2 = g + cost
if g2 < best_g.get(nb, float("inf")):
best_g[nb] = g2
heapq.heappush(frontier, (priority(g2, nb), g2, path + [nb]))
return None, expanded
ucs = lambda s, t: best_first(s, t, lambda g, n: g) # uninformed
greedy = lambda s, t: best_first(s, t, lambda g, n: h[n]) # informed
astar = lambda s, t: best_first(s, t, lambda g, n: g + h[n]) # informed
for name, algo in [("BFS", bfs), ("UCS", ucs), ("Greedy", greedy), ("A*", astar)]:
path, expanded = algo("S", "G")
print(f"{name:7} path={'-'.join(path):10} cost={path_cost(path):2} expanded={' '.join(expanded)}")
Output:
BFS path=S-A-G cost=13 expanded=S A B E C G
UCS path=S-A-B-C-G cost= 8 expanded=S A E F B H C G
Greedy path=S-B-C-G cost= 9 expanded=S B C G
A* path=S-A-B-C-G cost= 8 expanded=S A B C G
What the run shows:
- BFS finds the path with the fewest edges (S-A-G), but it ignores edge costs, so that path costs 13.
- UCS finds the cheapest path (cost 8) but expands 8 nodes, including the dead-end branch E-F-H, because those nodes are cheap to reach.
- Greedy best-first expands only 4 nodes, but it trusts
halone: B looks closer than A, so it returns S-B-C-G with cost 9, which is not optimal. - A* returns the same optimal path as UCS while expanding 5 nodes. The heuristic tells it that E, F and H are far from the goal, so it never opens them.
This is the practical trade-off in one example: uninformed UCS reaches the best answer by brute force, greedy search is quick but can be wrong, and A* gets the best answer with less work when the heuristic is admissible.
When to use which
- Use uninformed search when no sensible heuristic exists, when the state space is small, or when you need a baseline to check a heuristic method against. BFS suits unweighted graphs such as "fewest moves" puzzles; UCS suits weighted graphs; IDDFS suits deep spaces where memory is tight.
- Use informed search when the space is large and you can measure "distance to goal": route planning on maps, game pathfinding on grids, the 8-puzzle and 15-puzzle, robot motion planning and scheduling. A* is the default when the path must be optimal; greedy best-first or beam search are used when a good-enough answer fast is acceptable.
- Check the heuristic. An inadmissible heuristic makes A* faster but can return a non-optimal path. A heuristic that is expensive to compute can make an informed search slower overall than a blind one.
Problems such as the water jug problem are useful practice: solve them once with BFS and once with a heuristic, and compare how many states each one visits. For a wider list of methods, see heuristic search techniques in AI.
Common mistakes in exam answers
- "Informed search is always faster." It usually expands fewer nodes, but a poor or costly heuristic can remove that advantage.
- "Informed search always finds the best solution." Only some informed algorithms are optimal. Greedy best-first is not, and A* is optimal only with an admissible (for graph search, consistent) heuristic.
- "Blind search is random." It is systematic; it just has no estimate of distance to the goal.
- Mixing up g(n) and h(n).
g(n)is the known cost from the start ton;h(n)is the estimated cost fromnto the goal.
FAQs
Why is uninformed search called blind search?
Because it has no information about where the goal is beyond the goal test. It cannot rank non-goal states, so it explores them in a fixed order such as level by level or deepest first.
Is A* informed or uninformed?
A* is an informed search algorithm. It ranks nodes by f(n) = g(n) + h(n), where h(n) is a heuristic estimate of the remaining cost to the goal.
Is uniform-cost search informed?
No. Uniform-cost search uses only g(n), the cost already paid from the start, which comes from the problem definition. It is A* with h(n) = 0 for every node.
What is an admissible heuristic?
A heuristic that never overestimates the true cost from a node to the goal. With an admissible heuristic, A* tree search always returns an optimal solution.


