SlideShare a Scribd company logo
What is A * Search? What is Heuristic
Search? What is Tree search Algorithm?
Updated: Feb 27
What is a Search Algorithm?
Moving from one place to another is a task that we humans do almost every day. We
try to find the shortest path that enables us to reach our destinations faster and make
the whole process of travelling as efficient as possible. In the old days, we would trial
and error with the paths available and had to assume which path taken was shorter
or longer.
Table Of Contents
What is a Search Algorithm?
Tree search Algorithm
Breadth-First Search
Depth-First Search
Bidirectional Search
Uniform Cost Search
Iterative Deepening Depth-First Search
Heuristic Search
Manhattan distance
Pure Heuristic Search
A * Search
Formula
A * Search Explanation
More
Jobs
Now, we have algorithms that can help us find the shortest paths virtually. We just
need to add costs (time, money etc.) to the graphs or maps and the algorithm finds us
the path that we need to take to reach our destination as quick as possible. Many
algorithms were developed through the years for this problem and A* is one the most
popular algorithms out there.
Tree search Algorithm
A tree structure is a hierarchy of linked nodes where each node represents a
particular state. Nodes have none, one or more child nodes. A solution is a path from
the "root" node to a "goal" node. Tree search algorithms attempt to find a solution by
traversing the tree structure - starting at the root node and examining the child
nodes in a systematic way.
Tree search algorithms differ by the order in which nodes are traversed and can be
classified into two main groups:
● Blind search algorithms (e.g. "Breadth-first" and "Depth-first") use
a fixed strategy to methodically traverse the search tree. Blind search is
not suitable for complex problems as the the large search space makes
them impractical given time and memory constraints.
● Best-first search algorithms (e.g. "Greedy" and "A*") use a
heuristic function to determine the order in which nodes are traversed,
giving preference to states that are judged to be most likely to reach the
required goal. Using a "heuristic" search strategy reduces the search
space to a more manageable size.
A search strategy is complete if it is guaranteed to find a solution if one exists. A
search strategy is optimal if it is guaranteed to find the best solution when several
solutions exists.
Breadth-First Search
It starts from the root node, explores the neighboring nodes first and moves towards
the next level neighbors. It generates one tree at a time until the solution is found. It
can be implemented using FIFO queue data structure. This method provides shortest
path to the solution.
If branching factor (average number of child nodes for a given node) = b and depth =
d,
then number of nodes at level d = bd. The total no of nodes created in worst case is b
+ b2 + b3 + … + bd.
Disadvantage − Since each level of nodes is saved for creating next one, it
consumes a lot of memory space. Space requirement to store nodes is exponential.
Its complexity depends on the number of nodes. It can check duplicate nodes.
BFS Search
Depth-First Search
It is implemented in recursion with LIFO stack data structure. It creates the same set
of nodes as Breadth-First method, only in the different order.
As the nodes on the single path are stored in each iteration from root to leaf node, the
space requirement to store nodes is linear. With branching factor b and depth as m,
the storage space is bm.
Disadvantage − This algorithm may not terminate and go on infinitely on one path.
The solution to this issue is to choose a cut-off depth. If the ideal cut-off is d, and if
chosen cut-off is lesser than d, then this algorithm may fail. If chosen cut-off is more
than d, then execution time increases.
Its complexity depends on the number of paths. It cannot check duplicate nodes.
DFS Search
Bidirectional Search
It searches forward from initial state and backward from goal state till both meet to
identify a common state.
The path from initial state is concatenated with the inverse path from the goal state.
Each search is done only up to half of the total path.
Uniform Cost Search
Sorting is done in increasing cost of the path to a node. It always expands the least
cost node. It is identical to Breadth First search if each transition has the same cost.
It explores paths in the increasing order of cost.
Disadvantage − There can be multiple long paths with the cost ≤ C*. Uniform Cost
search must explore them all.
Iterative Deepening Depth-First Search
It performs depth-first search to level 1, starts over, executes a complete depth-first
search to level 2, and continues in such way till the solution is found.
It never creates a node until all lower nodes are generated. It only saves a stack of
nodes. The algorithm ends when it finds a solution at depth d. The number of nodes
created at depth d is bd and at depth d-1 is bd-1
Heuristic Search
To solve large problems with large number of possible states, problem-specific
knowledge needs to be added to increase the efficiency of search algorithms.
Heuristic Evaluation Functions
They calculate the cost of optimal path between two states. A heuristic function for
sliding-tiles games is computed by counting number of moves that each tile makes
from its goal state and adding these number of moves for all tiles.
There are different methods to calculate the Heuristic value. Euclidean distance is
one of them. It is also called a straight-line method. If we calculate distance we will
R1 is the right optimal path to follow.
Heuristic Search
Manhattan distance
Manhattan distance is another method to calculate an optimal path. Let’s understand
this by the 8-Puzzle problem.
Let's calculate the Manhattan distance from a start position to a goal position. If you
see ‘1’ is on the same position in goal
state so we do not have to move vertically or horizontally so distance will be zero.
Look at ‘2’ in the goal state, we have to
move one step left movement will be one. Similarly, we calculate manhattan distance
for all states by moving the number in
start state and chooses the state which has less manhattan value.
Heuristic State
Pure Heuristic Search
It expands nodes in the order of their heuristic values. It creates two lists, a closed
list for the already expanded nodes and an open list for the created but unexpanded
nodes.
In each iteration, a node with a minimum heuristic value is expanded, all its child
nodes are created and placed in the closed list. Then, the heuristic function is applied
to the child nodes and they are placed in the open list according to their heuristic
value. The shorter paths are saved and the longer ones are disposed.
A * Search
(What is heuristic function in ai, What is
heuristic search in ai)
What exactly is the A* algorithm? It is an advanced BFS algorithm that searches for
shorter paths first rather than the longer paths. A* is optimal as well as a complete
algorithm.
Optimal meaning that A* is sure to find the least cost from the source to the
destination and Complete meaning that it is going to find all the paths that are
available to us from the source to the destination.
So that makes A* the best algorithm right? Well, in most cases, yes. But A* is slow
and also the space it requires is a lot as it saves all the possible paths that are
available to us. This makes other faster algorithms have an upper hand over A* but it
is nevertheless, one of the best algorithms out there.
Formula
F = G + H
F – F is the parameter of A* which is the sum of the other parameters G and H and is
the least cost from one node to the next node. This parameter is responsible for
helping us find the most optimal path from our source to destination.
● G – G is the cost of moving from one node to the other node. This
parameter changes for every node as we move up to find the most
optimal path.
● H – H is the heuristic/estimated path between the current code to the
destination node. This cost is not actual but is, in reality, a guess cost
that we use to find which could be the most optimal path between our
source and destination.
A * Search Explanation
Consider a square grid having many obstacles and we are given a starting cell and a
target cell. We want to reach the target cell from the starting cell as quickly as
possible. Here A* Search Algorithm comes to the rescue.
What A* Search Algorithm? does is that at each step it picks the node according
to a value-‘Ff’ which is a parameter equal to the sum of two other parameters – ‘G’
and ‘H’. At each step it picks the node/cell having the lowest ‘F’, and process that
node/cell.
We define ‘G’ and ‘H’ as simply as possible below
G = the movement cost to move from the starting point to a given square on the grid,
following the path generated to get there.
H = the estimated movement cost to move from that given square on the grid to the
final destination. This is often referred to as the heuristic, which is nothing but a kind
of smart guess. We really don’t know the actual distance until we find the path,
because all sorts of things can be in the way (walls, water, etc.).
Let’s understand A* search technique with an example.
The values marked in red are estimated values or heuristic value. We find this value
with help of BFS technique. Lets we
want to go to start node (S) to goal node (G), the other node like B,F,C,E and D are
the n nodes. The cost to reach from S
node to B node is 4 similarly for other node is given. Let’s calculate cost.
f(n)=g(n)+h(n)
f(S) = 0+14=14
From S either we move to B or C.
S ----->B or S-->C
f(n)=4+12=16, f(n)=3+11=14, we can see the total cost is less in moving from S-->C
so we move from S-->C. This way we
follow this technique.
A * Search
A * Search Algorithm
● Add start node to list
● For all the neighbouring nodes, find the least cost F node
● Switch to the closed list
● For 8 nodes adjacent to the current node
● If the node is not reachable, ignore it. Else
● If the node is not on the open list, move it to the open list and
calculate f, g, h.
● If the node is on the open list, check if the path it offers is less
than the current path and change to it if it does so.
● Stop working when
● You find the destination
● You cannot find the destination going through all possible points
Pseudo-Code of the Algorithm
1. let the openList equal empty list of nodes
2. let the closedList equal empty list of nodes
3. put the startNode on the openList (leave it's f at zero)
4. while the openList is not empty
5. let the currentNode equal the node with
the least f value
6. remove the currentNode from the openList
7. add the currentNode to the closedList
8. if currentNode is the goal10.
9. You've found the end!
10. let the children of the currentNode equal
the adjacent nodes
11. for each child in the children
12. if child is in the closedList
13. continue to beginning of for
loop
14. child.g = currentNode.g + distance
between child and current
15. child.h = distance from child to
end
16. child.f = child.g + child.h
17. if child.position is in the
openList's nodes positions
18. if the child.g is higher than
the openList node's g
19. continue to
beginning of for loop
20. add the child to the openList
More
Turn Text To Speech With Human Like Voices
AI Engine For Professionals. Great Conversions, Low Refund Rate! Easily Generate
Sales Scripts And Video Audios Without Recording Anything.
Human Synthesys Studio
Human Synthesys Studio (view mobile). Finally, Your Customers Can Have A Real
Human Say Exactly What They Type In Any Video.
Gcse Maths In Four Weeks
Gcse Maths In Four Weeks - A Video Course For Students Taking The UK Gcse
Maths Exam.
Jobs
Apply by simple Clicking
Important post on AI Click here

More Related Content

Similar to What is A * Search? What is Heuristic Search? What is Tree search Algorithm?

A Star Search
A Star SearchA Star Search
Unit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution'sUnit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution's
Harsha Patel
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
DataminingTools Inc
 
AI: AI & problem solving
AI: AI & problem solvingAI: AI & problem solving
AI: AI & problem solving
Datamining Tools
 
AI_Lecture2.pptx
AI_Lecture2.pptxAI_Lecture2.pptx
AI_Lecture2.pptx
saadurrehman35
 
informed search.pptx
informed search.pptxinformed search.pptx
informed search.pptx
SoundariyaSathish
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
Dr. C.V. Suresh Babu
 
lecture 6 AI - A star.pdf
lecture 6 AI - A star.pdflecture 6 AI - A star.pdf
lecture 6 AI - A star.pdf
HassanElalfy4
 
Heuristic or informed search
Heuristic or informed searchHeuristic or informed search
Heuristic or informed search
HamzaJaved64
 
AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
AnkitaVerma776806
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2chandsek666
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
ananth
 
Comparison of various heuristic
Comparison of various heuristicComparison of various heuristic
Comparison of various heuristic
ijaia
 
3.informed search
3.informed search3.informed search
3.informed search
KONGU ENGINEERING COLLEGE
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
Yousef Aburawi
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
Nazir Ahmed
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
Nazir Ahmed
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
BaliThorat1
 
Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...
KarpagaPriya10
 

Similar to What is A * Search? What is Heuristic Search? What is Tree search Algorithm? (20)

A Star Search
A Star SearchA Star Search
A Star Search
 
Unit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution'sUnit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution's
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
AI: AI & problem solving
AI: AI & problem solvingAI: AI & problem solving
AI: AI & problem solving
 
artifical intelligence final paper
artifical intelligence final paperartifical intelligence final paper
artifical intelligence final paper
 
AI_Lecture2.pptx
AI_Lecture2.pptxAI_Lecture2.pptx
AI_Lecture2.pptx
 
informed search.pptx
informed search.pptxinformed search.pptx
informed search.pptx
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
lecture 6 AI - A star.pdf
lecture 6 AI - A star.pdflecture 6 AI - A star.pdf
lecture 6 AI - A star.pdf
 
Heuristic or informed search
Heuristic or informed searchHeuristic or informed search
Heuristic or informed search
 
AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
 
Comparison of various heuristic
Comparison of various heuristicComparison of various heuristic
Comparison of various heuristic
 
3.informed search
3.informed search3.informed search
3.informed search
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

What is A * Search? What is Heuristic Search? What is Tree search Algorithm?

  • 1. What is A * Search? What is Heuristic Search? What is Tree search Algorithm? Updated: Feb 27 What is a Search Algorithm? Moving from one place to another is a task that we humans do almost every day. We try to find the shortest path that enables us to reach our destinations faster and make the whole process of travelling as efficient as possible. In the old days, we would trial and error with the paths available and had to assume which path taken was shorter or longer. Table Of Contents What is a Search Algorithm? Tree search Algorithm Breadth-First Search Depth-First Search Bidirectional Search Uniform Cost Search Iterative Deepening Depth-First Search Heuristic Search
  • 2. Manhattan distance Pure Heuristic Search A * Search Formula A * Search Explanation More Jobs Now, we have algorithms that can help us find the shortest paths virtually. We just need to add costs (time, money etc.) to the graphs or maps and the algorithm finds us the path that we need to take to reach our destination as quick as possible. Many algorithms were developed through the years for this problem and A* is one the most popular algorithms out there. Tree search Algorithm A tree structure is a hierarchy of linked nodes where each node represents a particular state. Nodes have none, one or more child nodes. A solution is a path from the "root" node to a "goal" node. Tree search algorithms attempt to find a solution by traversing the tree structure - starting at the root node and examining the child nodes in a systematic way. Tree search algorithms differ by the order in which nodes are traversed and can be classified into two main groups:
  • 3. ● Blind search algorithms (e.g. "Breadth-first" and "Depth-first") use a fixed strategy to methodically traverse the search tree. Blind search is not suitable for complex problems as the the large search space makes them impractical given time and memory constraints. ● Best-first search algorithms (e.g. "Greedy" and "A*") use a heuristic function to determine the order in which nodes are traversed, giving preference to states that are judged to be most likely to reach the required goal. Using a "heuristic" search strategy reduces the search space to a more manageable size. A search strategy is complete if it is guaranteed to find a solution if one exists. A search strategy is optimal if it is guaranteed to find the best solution when several solutions exists. Breadth-First Search It starts from the root node, explores the neighboring nodes first and moves towards the next level neighbors. It generates one tree at a time until the solution is found. It can be implemented using FIFO queue data structure. This method provides shortest path to the solution. If branching factor (average number of child nodes for a given node) = b and depth = d,
  • 4. then number of nodes at level d = bd. The total no of nodes created in worst case is b + b2 + b3 + … + bd. Disadvantage − Since each level of nodes is saved for creating next one, it consumes a lot of memory space. Space requirement to store nodes is exponential. Its complexity depends on the number of nodes. It can check duplicate nodes. BFS Search
  • 5. Depth-First Search It is implemented in recursion with LIFO stack data structure. It creates the same set of nodes as Breadth-First method, only in the different order. As the nodes on the single path are stored in each iteration from root to leaf node, the space requirement to store nodes is linear. With branching factor b and depth as m, the storage space is bm. Disadvantage − This algorithm may not terminate and go on infinitely on one path. The solution to this issue is to choose a cut-off depth. If the ideal cut-off is d, and if chosen cut-off is lesser than d, then this algorithm may fail. If chosen cut-off is more than d, then execution time increases. Its complexity depends on the number of paths. It cannot check duplicate nodes.
  • 6. DFS Search Bidirectional Search It searches forward from initial state and backward from goal state till both meet to identify a common state. The path from initial state is concatenated with the inverse path from the goal state. Each search is done only up to half of the total path. Uniform Cost Search Sorting is done in increasing cost of the path to a node. It always expands the least cost node. It is identical to Breadth First search if each transition has the same cost. It explores paths in the increasing order of cost. Disadvantage − There can be multiple long paths with the cost ≤ C*. Uniform Cost search must explore them all. Iterative Deepening Depth-First Search It performs depth-first search to level 1, starts over, executes a complete depth-first search to level 2, and continues in such way till the solution is found.
  • 7. It never creates a node until all lower nodes are generated. It only saves a stack of nodes. The algorithm ends when it finds a solution at depth d. The number of nodes created at depth d is bd and at depth d-1 is bd-1 Heuristic Search To solve large problems with large number of possible states, problem-specific knowledge needs to be added to increase the efficiency of search algorithms. Heuristic Evaluation Functions They calculate the cost of optimal path between two states. A heuristic function for sliding-tiles games is computed by counting number of moves that each tile makes from its goal state and adding these number of moves for all tiles. There are different methods to calculate the Heuristic value. Euclidean distance is one of them. It is also called a straight-line method. If we calculate distance we will R1 is the right optimal path to follow.
  • 8. Heuristic Search Manhattan distance Manhattan distance is another method to calculate an optimal path. Let’s understand this by the 8-Puzzle problem. Let's calculate the Manhattan distance from a start position to a goal position. If you see ‘1’ is on the same position in goal state so we do not have to move vertically or horizontally so distance will be zero. Look at ‘2’ in the goal state, we have to move one step left movement will be one. Similarly, we calculate manhattan distance for all states by moving the number in start state and chooses the state which has less manhattan value.
  • 9. Heuristic State Pure Heuristic Search It expands nodes in the order of their heuristic values. It creates two lists, a closed list for the already expanded nodes and an open list for the created but unexpanded nodes. In each iteration, a node with a minimum heuristic value is expanded, all its child nodes are created and placed in the closed list. Then, the heuristic function is applied to the child nodes and they are placed in the open list according to their heuristic value. The shorter paths are saved and the longer ones are disposed. A * Search
  • 10. (What is heuristic function in ai, What is heuristic search in ai) What exactly is the A* algorithm? It is an advanced BFS algorithm that searches for shorter paths first rather than the longer paths. A* is optimal as well as a complete algorithm. Optimal meaning that A* is sure to find the least cost from the source to the destination and Complete meaning that it is going to find all the paths that are available to us from the source to the destination. So that makes A* the best algorithm right? Well, in most cases, yes. But A* is slow and also the space it requires is a lot as it saves all the possible paths that are available to us. This makes other faster algorithms have an upper hand over A* but it is nevertheless, one of the best algorithms out there. Formula F = G + H F – F is the parameter of A* which is the sum of the other parameters G and H and is the least cost from one node to the next node. This parameter is responsible for helping us find the most optimal path from our source to destination.
  • 11. ● G – G is the cost of moving from one node to the other node. This parameter changes for every node as we move up to find the most optimal path. ● H – H is the heuristic/estimated path between the current code to the destination node. This cost is not actual but is, in reality, a guess cost that we use to find which could be the most optimal path between our source and destination. A * Search Explanation Consider a square grid having many obstacles and we are given a starting cell and a target cell. We want to reach the target cell from the starting cell as quickly as possible. Here A* Search Algorithm comes to the rescue. What A* Search Algorithm? does is that at each step it picks the node according to a value-‘Ff’ which is a parameter equal to the sum of two other parameters – ‘G’ and ‘H’. At each step it picks the node/cell having the lowest ‘F’, and process that node/cell. We define ‘G’ and ‘H’ as simply as possible below G = the movement cost to move from the starting point to a given square on the grid, following the path generated to get there. H = the estimated movement cost to move from that given square on the grid to the final destination. This is often referred to as the heuristic, which is nothing but a kind of smart guess. We really don’t know the actual distance until we find the path, because all sorts of things can be in the way (walls, water, etc.).
  • 12. Let’s understand A* search technique with an example. The values marked in red are estimated values or heuristic value. We find this value with help of BFS technique. Lets we want to go to start node (S) to goal node (G), the other node like B,F,C,E and D are the n nodes. The cost to reach from S node to B node is 4 similarly for other node is given. Let’s calculate cost. f(n)=g(n)+h(n) f(S) = 0+14=14 From S either we move to B or C. S ----->B or S-->C f(n)=4+12=16, f(n)=3+11=14, we can see the total cost is less in moving from S-->C so we move from S-->C. This way we follow this technique.
  • 13. A * Search A * Search Algorithm ● Add start node to list ● For all the neighbouring nodes, find the least cost F node ● Switch to the closed list ● For 8 nodes adjacent to the current node ● If the node is not reachable, ignore it. Else ● If the node is not on the open list, move it to the open list and calculate f, g, h. ● If the node is on the open list, check if the path it offers is less than the current path and change to it if it does so. ● Stop working when ● You find the destination
  • 14. ● You cannot find the destination going through all possible points Pseudo-Code of the Algorithm 1. let the openList equal empty list of nodes 2. let the closedList equal empty list of nodes 3. put the startNode on the openList (leave it's f at zero) 4. while the openList is not empty 5. let the currentNode equal the node with the least f value 6. remove the currentNode from the openList 7. add the currentNode to the closedList 8. if currentNode is the goal10. 9. You've found the end! 10. let the children of the currentNode equal the adjacent nodes 11. for each child in the children 12. if child is in the closedList 13. continue to beginning of for loop 14. child.g = currentNode.g + distance between child and current 15. child.h = distance from child to end 16. child.f = child.g + child.h 17. if child.position is in the openList's nodes positions 18. if the child.g is higher than the openList node's g 19. continue to beginning of for loop 20. add the child to the openList More Turn Text To Speech With Human Like Voices
  • 15. AI Engine For Professionals. Great Conversions, Low Refund Rate! Easily Generate Sales Scripts And Video Audios Without Recording Anything. Human Synthesys Studio Human Synthesys Studio (view mobile). Finally, Your Customers Can Have A Real Human Say Exactly What They Type In Any Video. Gcse Maths In Four Weeks Gcse Maths In Four Weeks - A Video Course For Students Taking The UK Gcse Maths Exam. Jobs Apply by simple Clicking Important post on AI Click here