No, using f(v) = (h(v) + g(v))/2 instead of f(v) = h(v) + g(v) in the A* algorithm will not result in exactly the same run.
The reason is that the A* algorithm relies on the property that f(v) is an admissible heuristic, meaning that it never overestimates the true cost of reaching the goal. When f(v) = h(v) + g(v), the algorithm is guaranteed to find the optimal solution because h(v) is an admissible heuristic and g(v) is the true cost of reaching v from the starting node.
However, when f(v) = (h(v) + g(v))/2, the algorithm is no longer guaranteed to find the optimal solution. This is because the weighted average of h(v) and g(v) can result in a value that is not admissible, meaning that it may overestimate or underestimate the true cost of reaching the goal.
In particular, using f(v) = (h(v) + g(v))/2 can lead to the following issues:
- Inadmissible heuristic: The weighted average of
h(v) and g(v) may not be admissible, which can cause the algorithm to explore nodes that are not on the optimal path.
- Different node selection: The algorithm may select different nodes to explore at each step, which can result in a different search tree and potentially a suboptimal solution.
- Loss of optimality: The algorithm may not find the optimal solution, even if it exists, because the weighted average of
h(v) and g(v) can lead to a suboptimal path.
That being said, it's worth noting that the A* algorithm with f(v) = (h(v) + g(v))/2 may still find a good solution, especially if the heuristic h(v) is relatively accurate and the graph is relatively simple. However, it's not guaranteed to find the optimal solution, and the algorithm's performance may degrade as the graph size and complexity increase.
In summary, using f(v) = (h(v) + g(v))/2 instead of f(v) = h(v) + g(v) in the A* algorithm can result in a different search tree and potentially a suboptimal solution, and it's not recommended to use this modification in practice.