Artificial intelligence • Original RRTutors lesson
Uninformed Search: BFS, DFS, and Uniform-Cost Search
Compare search strategies that use no estimate of distance to the goal.
Concept and explanation
Breadth-first search explores by depth and finds a fewest-step solution when all actions have equal cost. Depth-first search uses less frontier memory in some cases but can follow a long or infinite branch. Uniform-cost search expands the least-cost path so far and is suitable for non-negative variable action costs.
How to apply it
Choose the frontier structure from the objective: queue for BFS, stack for DFS, and priority queue for uniform cost.
Worked example
In a weighted road network, a route with fewer edges may cost more than a longer route, so BFS is not enough.
Illustrative Python example
from collections import deque
frontier = deque([start])
visited = {start}
while frontier:
state = frontier.popleft()
for neighbor in successors(state):
if neighbor not in visited:
visited.add(neighbor)
frontier.append(neighbor)
Expected result
The queue explores nodes in nondecreasing depth when every edge has equal cost.
Limitations and cautions
Search completeness and optimality depend on branching, cycles, costs, and termination assumptions.
Practice exercise
Compare BFS and uniform-cost search on a graph with one expensive direct edge and a cheaper multi-edge path.
Key takeaway: Search guarantees come from the frontier policy and assumptions about the problem.