Search code examples
algorithmartificial-intelligence

Value of f in A* algorithm


In A* algorithm, if g=0 and h=0 then what will be the result of f?

I know f(x)=g(x)+h(x). So it is true that f(x) will be zero?


Solution

  • f(x) would be 0. But this should hardly ever occur. g(x)=0 means you had no costs to reach x (should only be the case for the starting point)
    h(x)=0 means the heuristics says that the costs to reach the goal from x costs not more than 0 (means that you are at the goal)

    so f(x)=0 should only be possible if you start at the goal.