A Search Algorithm: Krishna Kumar (IT2018/122) Kishan Raj (IT2018/025) Aavriti Dutta (IT2018/101)
A Search Algorithm: Krishna Kumar (IT2018/122) Kishan Raj (IT2018/025) Aavriti Dutta (IT2018/101)
Presented By Group 19
Krishna Kumar(IT2018/122)
Kishan Raj(IT2018/025)
Aavriti Dutta(IT2018/101)
HEURISTIC SEARCH
A* search is the most commonly known form of best-first search.It uses heuristic function h(n), and the
cost to reach the node n from the start state ie. g(n).This search algorithm expands less search tree and
provides optimal result faster. And it is also worth mentioning that many games and web-based maps
use this algorithm to find the shortest path very efficiently.
It is formulated in terms of weighted graphs: starting from a specific starting node of a graph, it aims to
find a path to the given goal node having the smallest cost (least distance travelled, shortest time, etc.)
It does this by maintaining a tree of path originating at the start node and extending those paths one
edge at a time until the goal node is reached.
At each point in the search space, only those nodes are expanded which have the lowest value of f(n),
and the algorithm terminates when the goal node is found.
Function of A* Search Algorithm
f(n) = g(n) + h(n)
g(n) : the exact cost of moving from the Starting node to the
current node. Basically, it is the sum of all the cells that
have been visited since leaving the first cell.
Step2: Check if the start node is empty or not, if empty then return failure and stop.
Step3: Select the node from next to start which has the smallest value of evaluation
function (g+h), if node n is goal node then return success and stop.
Step4: Expand node n and generate all of its successors, and put n into the memory. For
each successor n', check whether n' is already in the memory or not, if not then
compute evaluation function for n' and place into memory.
Step5: Repeat the above steps untill the goal node is reached.
Example of A* Search
Let us understand the process of A* search algorithm with the help of an example
S → Starting Node
G → Goal Node
f(n)=g(n)+h(n)
Step-1
Initialization: f(S)=0+5=5
(S→ A) is chosen
Step-3
Iteration2: Cost for path
S→A→C=1+1+2=4
S→A→B=1+2+4=7
S→G=0+10=10
(S→A→C) is chosen
Step-4
Iteration3: Cost for path
S→A→C→G=1+1+4=6
S→A→C→D=1+1+3+6=11
S→A→B=1+2+4=7
S→G=0+10=10
S→A→C→G
Tree
Advantages of A* search algorithm:-
iv. It does not always produce the shortest path as it is mostly based on heuristic and
approximation.
v. A* algorithm has some complexity issues as we have to explore every nodes to find the
optimal path.
vi. The algorithm is complete only if the branching factor is finite and every action
has fixed cost.
Points to be remembered:-
i. A* algorithm returns the path which occurred first, and it does not search
for all remaining paths.
ii. The efficiency of A* algorithm depends on the quality of heuristic.
iii. A* algorithm expands all nodes which satisfy the condition f(n).
iv. It is not practical for various large scale problems because there is
memory requirement as it keeps all generated nodes in the memory.
v. Time Complexity: The time complexity of A* search algorithm depends on
heuristic function, and the number of nodes expanded is exponential to the
depth of solution “d”.So the time complexity is O(b^d), where “b” is the
branching factor.
vi. Space Complexity: The space complexity of A* search algorithm
is O(b^d).
Conclusion:-
A* is a mighty algorithm in Artificial Intelligence with a wide range
of usage. However, it is only as good as its heuristic function( which
can be highly variable considering the nature of a problem).
A* is the most popular choice for pathfinding because it’s reasonably
flexible.
It has found applications in many software systems, from Machine
Learning and search Optimization to game development where
characters navigate through complex terrain and obstacles to reach the
player.
THANK
YOU!