~/ learn/ comp-456/ cards/ Search & heuristic drills
1 of 5

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.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/faafe441-119e-4090-b2f1-5bbf8fd128ff/flashcard utf-8 LF