Theory

Best-First Search is an informed search algorithm that explores a search space by prioritizing nodes based on a heuristic evaluation function. It begins at the start node and selects the most promising node to explore next, guided by the heuristic estimate of each node's proximity to the goal. This process continues iteratively until the goal node is reached or no more nodes remain to explore.

Best-First Search algorithm:
  1. Initialization:
    • Begin at the start node.
  2. Priority Queue:
    • a priority store nodes yet to be explored, sorted based on some heuristic or evaluation function. The priority queue ensures that nodes closer to the goal are explored first..
  3. Expansion of Nodes:
    • From the current node, expand to neighboring nodes.
    • Calculate the heuristic value for each neighboring node. This heuristic estimates how close each node is to the goal.
    • Add neighboring nodes to the priority queue based on their heuristic values, with nodes closer to the goal having higher priority.
  4. Node Selection:
    • Select the node with the highest priority from the priority queue. This node represents the most promising path towards the goal.
  5. Goal check
    • Check if the selected node is the goal node. If it is, the search terminates, and the optimal path is found.
  6. Expansion and Iteration:
    • If the selected node is not the goal
    • Expand the selected node by considering its neighboring nodes.
    • Calculate heuristic values for these neighboring nodes and add them to the priority queue.
    • Repeat steps 4-6 until the goal node is found or the priority queue becomes empty.
  7. Termination:
    • If the priority queue becomes empty and the goal node is not found, the search terminates without finding a solution.