Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why DFS is not optimal but BFs is optimal

I have this question in my mind for long but never got reasonable answer for that :

Usually in artifitial intelligent course when it comes to search it is always said that BFS is optimal but DFS is not but I can come up with many example that shows with DFS we can even get the answer faster. So can anyone explain it ? Am I missing something?

like image 443
HMdeveloper Avatar asked Jan 21 '14 16:01

HMdeveloper


1 Answers

Optimal as in "produces the optimal path", not "is the fastest algorithm possible". When searching a state space for a path to a goal, DFS may produce a much longer path than BFS. Note that BFS is only optimal when actions are unweighted; if different actions have different weights, you need something like A*.

like image 156
user2357112 supports Monica Avatar answered Nov 04 '22 10:11

user2357112 supports Monica