Skip to content
Related Articles

Related Articles

Difference between Best-First Search and A* Search?

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 06 Sep, 2022
Improve Article
Save Article

Best-First Search:

Best-First search is a searching algorithm used to find the shortest path which uses distance as a heuristic. The distance between the starting node and the goal node is taken as heuristics. It defines the evaluation function for each node n in the graph as f(n) = h(n) where h(n) is heuristics function.

A*Search:  

A*search is a searching algorithm used to find the shortest path which calculates the cost of all its neighboring nodes and selects the minimum cost node. It defines the evaluation function f(n) = g(n) + h(n) where, h(n) is heuristics function and g(n) is the past knowledge acquired while searching.

Difference Between Best-first search and A*search:

The best-first search and A* search algorithm both define the evaluation function for each node n of the graph. This evaluation function is denoted by f(n). This evaluation function determines which node to be expanded first while searching. Both search algorithms mainly differ in their evaluation function. Here, f(n) is the evaluation function, g(n) is the past knowledge acquired while searching, and h(n) is the heuristics function. 

The difference between the best-fit and A* search algorithms is represented by the following table.

S

Parameters    

Best-First Search

      A* Search     

  1 Evaluation Function The evaluation function for best-first search is f(n) = h(n). The evaluation function for A* search is f(n) = h(n) + g(n).
  2 Past Knowledge This search algorithm does not involve past knowledge. This search algorithm involves past knowledge.
  3 Completeness Best-first search is not complete. A* search is complete.
  4 Optimal Best-first search is not optimal as the path found may not be optimal. A* search is optimal as the path found is always optimal.
  5 Time and Space Complexity

Its time complexity is O(bm) and space complexity can be polynomial.

where b is the branching and m is the maximum depth of the search tree 

Its time complexity is O(bm) and space complexity is also O(bm).

where b is the branching and m is the maximum depth of the search tree 

  6 Memory  It requires less memory. It requires more memory.
  7 Type of nodes kept It keeps all the fringe or border nodes in the memory while searching. It keeps all the nodes in the memory while searching.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!