BFS vs DFS data structures — type the two-line answer (Prolog-style comments)
BFS vs DFS data structures — type the two-line answer (Prolog-style comments)
Answer
% BFS: OPEN is a FIFO queue -> shortest path in moves % DFS: OPEN is a LIFO stack -> memory-cheap, not optimal
The single most-asked search distinction: queue ⇒ breadth-first ⇒ fewest-move-optimal; stack ⇒ depth-first ⇒ low memory but not shortest and needs a visited set.