Breadth-first search expands nodes level by level using a FIFO queue, guaranteeing the shallowest goal but using memory that grows with the frontier. Depth-first search expands one branch as far as it goes using a LIFO stack, using far less memory but finding goals in a different order and losing optimality.
BFS uses a queue; DFS uses a stack Algorithm Frontier Complete Optimal Memory BFS FIFO queue Yes Yes (equal costs) High: O(b^d) DFS LIFO stack Yes (finite) No Low: O(b*m) Iterative deepening Repeated DFS + depth limit Yes Yes (equal costs) Low: O(b*d)
Reading the expansion order
Watch the order in which nodes are expanded: BFS always expands all nodes at depth d before any at depth d+1, while DFS dives down one branch immediately. The expansion order list in the panel is the single clearest way to tell the two algorithms apart.