All simulations
Artificial intelligence
·
Search strategies
BFS vs DFS vs A*
Race search strategies through one maze and compare their work and paths.
+
−
Ready
0
Step
–
Shortest path
Expanding now
Frontier
Explored
Wall
Path found
Skip tour
Next
Quiz · BFS vs DFS vs A*
Question 1 of 5
Choose one
On a grid where every move costs 1, which strategies are guaranteed to find a shortest path?
BFS and A* with an admissible h
DFS and Greedy
Only DFS
Only Greedy
Choose one
A* is about to choose between two frontier cells: g = 6, h = 4 and g = 3, h = 8. Which does it expand?
g = 6, h = 4, since f = 10
g = 3, h = 8, since f = 11
g = 3, h = 8, since its g is smaller
Whichever was added first
Choose one
What happens to A* when h = 0 for every cell?
It behaves like uniform-cost search — here, like BFS
It behaves like DFS
It stops finding paths
It becomes Greedy best-first
Select all that apply
In the dead-end trap, why does Greedy best-first expand cells inside the U?
Cells inside the U have small h because they are close to G
Greedy ignores the cost already spent (g)
Greedy uses a stack like DFS
The heuristic overestimates there
Choose one
Which data structure gives DFS its behaviour?
A stack (newest first)
A queue (oldest first)
A priority queue on g + h
A priority queue on h
To improve
Your answers