Algorithms and Data Structures · Senior · Question 62 of 75

Why is DFS preferred over BFS for some puzzles despite BFS finding shortest solutions?

Explanation

With branching factor b and depth d, BFS keeps up to bᵈ states in its queue. Iterative deepening DFS gets the best of both: shortest solutions with O(d) memory, at the cost of repeating the shallow levels.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 62

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz