0% found this document useful (0 votes)
165 views

Best First Search

1. Heuristic search techniques use heuristic functions to estimate the cost from the current state to the goal state, guiding the search in a more efficient direction. 2. Best first search uses an evaluation function to prioritize exploring the most promising adjacent nodes first. It implements a priority queue to store nodes by their estimated cost to reach the goal. 3. The best first search algorithm can find the optimal solution when multiple paths exist, but has higher time complexity than breadth-first search due to the priority queue implementation.

Uploaded by

Gaurav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

Best First Search

1. Heuristic search techniques use heuristic functions to estimate the cost from the current state to the goal state, guiding the search in a more efficient direction. 2. Best first search uses an evaluation function to prioritize exploring the most promising adjacent nodes first. It implements a priority queue to store nodes by their estimated cost to reach the goal. 3. The best first search algorithm can find the optimal solution when multiple paths exist, but has higher time complexity than breadth-first search due to the priority queue implementation.

Uploaded by

Gaurav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ARTIFICIAL INTELLIGENCE /UNIT II /LECTURE IV

INFORMED OR HEURISTIC SEARCH TECHNIQUE


Heuristic is a technique which makes our search algorithm more efficient. It is a
problem specific knowledge that decreases expected search effort.
The heuristic search techniques use some functions to estimate the cost from
current state to the goal state. This function is known as heuristic function. The heuristic
function should be efficient enough to direct towards goal.
“A Heuristic function is a function that maps from problem state descriptions to
measure of desirability usually represented as number. The purpose of heuristic function is
to guide the search process in the most profitable directions by suggesting which path to
follow first when multiple paths are available.”

Characteristics of heuristic search:


• Heuristics are knowledge about domain, which help search and reasoning in its domain.
• Heuristic search incorporates domain knowledge to improve efficiency over blind search.
• Heuristic is a function that, when applied to a state, returns value as estimated merit of
state, with respect to goal. Heuristics might (for reasons) underestimate or overestimate the
merit of a state with respect to the goal.
• Heuristics that underestimate are desirable and called admissible.
• Heuristic evaluation function estimates likelihood of given state leading to goal state.
• Heuristic search function estimates cost from current state to goal, presuming function is
efficient.
Some of the important heuristic search techniques are:
(1) Generate and Test Search
(2) Best First Search
(3) Hill Climbing Search
(4) A* Search
Here we will discuss following heuristic search techniques:

Parul Saxena /Artificial Intelligence /Unit II /Lecture IV /14.04.2020 / Page 1 of 5


BEST FIRST SEARCH
In BFS and DFS, when we are at a node, we can consider any of the adjacent as next
node. So both BFS and DFS blindly explore paths without considering any cost function.
The idea of Best First Search is to use an evaluation function to decide which
adjacent is the most promising and then explore. Best First Search falls under the category
of Heuristic Search or Informed Search. We use a priority queue to store costs of nodes. So
the implementation is a variation of Breadth First Search, we just need to change Queue to
Priority Queue. Now let us consider the algorithm for best first search technique.
Algorithm:
Step 1: Place the starting node or root node into the queue.
Step 2: If the queue is empty, then stop and return failure.
Step 3: If the first element of the queue is our goal node, then stop and return success.
Step4: Else, remove the first element from the queue. Expand it and compute the estimated
goal distance for each child. Place the children in the queue in ascending order to the goal
distance in the form of the cost of the heuristic function.
Step 5: Go to Step2
Implementation:
Let us implement the above algorithm of Best First Search by taking the following suitable
example.

Figure 1: Best First Search

Parul Saxena /Artificial Intelligence /Unit II /Lecture IV /14.04.2020 / Page 2 of 5


Here heuristic function is the cost of reaching towards the goal node from the current node.
In the above figure we apply the best first search algorithm to find the node I :

Step 1: First of all we put the starting node S in the queue


S

Step 2: As S is not the goal node hence we remove s from the queue and arrange unvisited
neighbors of S in ascending order of their costs.
A C B

Step 3: As A is not the goal node hence we remove A from the queue and arrange all
unvisited neighbors of A in ascending order of their costs.
C B E D

Step 4: As C is not the goal node hence We remove C from queue and arrange all unvisited
neighbors of C in ascending order of their costs.
B H E D

Step 5: As B is not the goal node hence We remove B from the queue and arrange all
unvisited neighbors of B in ascending order of their costs.
H E D F G

Step 6: As H is not the goal node, hence we remove H from the queue and arrange all
unvisited neighbors of H in the ascending order of their costs.
I J E D F G

Parul Saxena /Artificial Intelligence /Unit II /Lecture IV /14.04.2020 / Page 3 of 5


Step 7: As I is the goal node and we terminate the search process.

Advantages:
 In this procedure at any way it will find the goal.
 It does not follow a single unfruitful path for a long time.
 It finds the minimal solution in case of multiple paths.

Disadvantages:
 BFS consumes large memory space.
 Its time complexity is more.
 It has long pathways, when all paths to a destination are on approximately the same
search depth.

Best first search is an instance of graph search algorithm in which a node is selected
for expansion based on the evaluation of function f (n). Traditionally, the node which is the
lowest evaluation is selected for the explanation because the evaluation measures distance
to the goal. Best first search can be implemented within general search frame work via a
priority queue, a data structure that will maintain the fringe in ascending order of the
function values.
This search algorithm serves as combination of depth first and breadth first search
algorithm. Best first search algorithm is often referred greedy algorithm this is because they
quickly attack the most desirable path as soon as its heuristic weight becomes the most
desirable.

Parul Saxena /Artificial Intelligence /Unit II /Lecture IV /14.04.2020 / Page 4 of 5


Analysis: The worst case time complexity for Best First Search is O(n* log n) where n is
number of nodes. In worst case, we may have to visit all nodes before we reach goal. Note
that priority queue is implemented using Min (or Max) Heap, and insert and remove
operations take O(log n) time. Performance of the algorithm depends on how well the cost
or evaluation function is designed.

EXERCISE

(1) Search the nodes J, K L and M in above Figure1 respectively using:


(i) Breadth First Search
(ii) Depth First Search
(iii) Best First Search

(2) Search the node F in the following Figure 2 using:


(i) Breadth First Search
(ii) Depth First Search
(iii) Best First Search

Figure 2

Parul Saxena /Artificial Intelligence /Unit II /Lecture IV /14.04.2020 / Page 5 of 5

You might also like