0% found this document useful (0 votes)
51 views9 pages

Heuristic Function - Aniket

Heuristic functions estimate the cost to reach the goal state from any given state and are used to guide search algorithms like best-first search and A* search. Best-first search uses heuristics to expand the most promising nodes first, but may not find the optimal solution, while A* search uses a heuristic plus path cost to always find the optimal solution. Both have exponential time and space complexity but A* is complete and optimal while best-first search is incomplete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views9 pages

Heuristic Function - Aniket

Heuristic functions estimate the cost to reach the goal state from any given state and are used to guide search algorithms like best-first search and A* search. Best-first search uses heuristics to expand the most promising nodes first, but may not find the optimal solution, while A* search uses a heuristic plus path cost to always find the optimal solution. Both have exponential time and space complexity but A* is complete and optimal while best-first search is incomplete.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Heuristic Function

Explanation :

Heuristic is a function which is used to implement the informed search


techniques and it finds the most promising path for solution.
The heuristic approach does not give the best solution every time, but it
guarantees to find a good solution in less time.
Heuristic function estimates how close a state is to the goal state. It is
represented by h(n), and it calculates the cost of an optimal path between
the pair of states. The value of the heuristic function is always positive

--- Presentation By Aniket


Two main algorithms which
uses Heuristic and informed
search:
• Best First Search
• A* Search Algorithm
Best First Search Algorithm
• It is a greedy approach to find the path which appears best at any
moment
• In this algorithm we expand the node which is closest to the goal node
and the minimum cost is calculated by the heuristic function
• It is implemented by priority queue
• Time Complexity: O(bm).
• Space Complexity: O(b m). Where, m is the maximum depth of the
search space.
• Incomplete
• Not optimal
Example

Example
Example
A* Search Algorithm
• It is one of the form of best first search technique which uses heuristic function to
find the best solution in reasonable time.

• A* search algorithm finds the shortest path through the search space using the
heuristic function. This search algorithm expands less search tree and provides
optimal result faster.
• A* algorithm uses f(n) = g(n)+h(n) value to choose paths.
• Time Complexity: O(b^d)
• Space Complexity: O(b^d)
• Complete
• Optimal
Question :
Initialization: {(S, 5)}
Iteration1: {(S--> A, 4), (S-->G, 10)}
Iteration2: {(S--> A-->C, 4), (S-->
A-->B, 7), (S-->G, 10)}
Iteration3: {(S--> A-->C--->G, 6),
(S--> A-->C--->D, 11), (S--> A-->B,
7), (S-->G, 10)}
Iteration 4 will give the final
result, as S--->A--->C--->G it
provides the optimal path with
cost 6.
Thank You

You might also like