You are on page 1of 5

S

B C
A

H
D L

E I J
F

G
Best First Search
● Create two empty lists
● Start from the inital node and add it to the ordered open list
● Next the below steps are repeated until the final node or endpoint is reached
● If the open list is empty exit the loop and return a False statement which says that the final node cannot
be reached
● Select the top node in the open list and move it to the closed list while keeping track of the parent node
● If the node removed is the endpoint node return a True statement meaning a path has been found and
moving the node to the closed list
● However if it is not the endpoint node then list down all the neighboring nodes of it and add them to the
open list
● According to the evaluation function re order the nodes.
Advantages and Disadvantages of Best First Search

Advantages:
1. Can switch between BFS and DFS, thus gaining the advantages of both.
2. More efficient when compared to DFS.

Disadvantages:
1. Chances of getting stuck in a loop are higher.
Generic Graph Search

● Repeat
○ select a path on the frontier. Let's call the path selected P.
○ if P is a path to a goal node, stop and return P,
○ remove P from the frontier
○ for each neighbor of the node at the end of P, extend P to that neighbour
and add the extended path to the frontier
● Until the frontier is empty. When it is empty there are no more solutions.

You might also like