SlideShare a Scribd company logo
Heuristic Search Algorithm
Lecture-12
Hema Kashyap
1
Best First Search
• Uniform Cost Search is a special case of the best first search algorithm. The algorithm
maintains a priority queue of nodes to be explored. A cost function f(n) is applied to each
node. The nodes are put in OPEN in the order of their f values. Nodes with smaller f(n)
values are expanded earlier. The generic best first search algorithm is outlined below.
2
Concept
Step 1: Traverse the root node
Step 2: Traverse any neighbour of the root node, that is maintaining a least distance
from the root node
and insert them in ascending order into the queue.
Step 3: Traverse any neighbour of neighbour of the root node, that is maintaining a
least distance from
the root node and insert them in ascending order into the queue
Step 4: This process will continue until we are getting the goal node
3
Example
Step 1:
Consider the node A as our root node. So the first element of the queue is A whish is not our
goal node, so remove it from the queue and find its neighbour that are to inserted in ascending
order.
A
Step 2:
The neighbours of A are B and C. They will be inserted into the queue in ascending order.
B C A(Expanded Node)
Step 3:
Now B is on the FRONT end of the queue. So calculate the neighbours of B that are maintaining
a least distance from the roof.
F E D C B(Expanded Node)
4
Step 4:
Now the node F is on the FRONT end of the queue. But as it has no further children, so remove it
from the queue and proceed further.
E D C F (Expanded Node)
Step 5:
Now E is the FRONT end. So the children of E are J and K. Insert them into the queue in
ascending order.
K J D C E(Expanded Node)
Step 6:
Now K is on the FRONT end and as it has no further children, so remove it and proceed further
J D C K(Expanded Node)
Step7:
Also, J has no corresponding children. So remove it and proceed further.
D C J(Expanded Node)
Step 8:
Now D is on the FRONT end and calculates the children of D and put it into the queue.
I C D(Expanded Node)
Step9:
Now I is the FRONT node and it has no children. So proceed further after removing this node
from the queue.
C I(Expanded Node)
5
Step 10:
Now C is the FRONT node .So calculate the neighbours of C that are to be inserted in
ascending order into the queue.
G H C(Expanded Node)
Step 11:
Now remove G from the queue and calculate its neighbour that is to insert in ascending
order into the queue.
M L H G(Expanded Node)
Step12:
Now M is the FRONT node of the queue which is our goal node. So stop here and exit.
L H M(Expanded Node)
6
Advantages
• It is more efficient than that of
BFS and DFS.
• Time complexity of Best first
search is much less than Breadth
first search.
• The Best first search allows us
to switch between paths by
gaining the benefits of both
breadth first and depth first
search. Because, depth first is
good because a solution can be
found without computing all
nodes and Breadth first search is
good because it does not get
trapped in dead ends.
Disadvantages
• Sometimes, it covers more distance than
our consideration.
7
Branch and Bound
• Branch and Bound is an algorithmic technique which finds the optimal solution by
keeping the best solution found so far.
• If partial solution can’t improve on the best it is abandoned, by this method the
number of nodes which are explored can also be reduced.
• It also deals with the optimization problems over a search that can be presented as
the leaves of the search tree.
• The usual technique for eliminating the sub trees from the search tree is called
pruning.
• For Branch and Bound algorithm we will use stack data structure.
8
Concept
Step 1: Traverse the root node.
Step 2: Traverse any neighbour of the root node that is maintaining least distance from
the root node.
Step 3: Traverse any neighbour of the neighbour of the root node that is maintaining
least distance from
the root node.
Step 4: This process will continue until we are getting the goal node.
9
Algorithm
Step 1: PUSH the root node into the stack.
Step 2: If stack is empty, then stop and return failure.
Step 3: If the top node of the stack is a goal node, then stop and return success.
Step 4: Else POP the node from the stack. Process it and find all its successors. Find
out the path containing all its successors as well as predecessors and then PUSH the
successors which are belonging to the minimum or shortest path.
Step 5: Go to step 5.
Step 6: Exit.
10
ExampleStep 1:
Consider the node A as our root node. Find its successors
i.e. B, C, F. Calculate the distance from the root and PUSH
them according to least distance.
A
B: 0+5 = 5 (The cost of A is 0 as it is the starting node)
F: 0+9 = 9
C: 0+7 = 7
Here B (5) is the least distance.
Step 2:
Now the stack will be
C F B(Top) A(Expanded)
As B is on the top of the stack so calculate the neighbours
of B.
D: 0+5+4 = 9
E: 0+5+6 = 11
The least distance is D from B. So it will be on the top of
the stack. 11
Step 3:
As the top of the stack is D. So calculate neighbours of D.
C F D(Top) B(Expanded)
C: 0+5+4+8 = 17
F: 0+5+4+3 = 12
The least distance is F from D and it is our goal node. So stop and return success.
Step 4:
C F(Top) D(Expanded)
Hence the searching path will be A-B -D-F
12
Advantages/Disadvantages
Advantages:
• As it finds the minimum path instead of finding the minimum successor so there
should not be any repetition.
• The time complexity is less compared to other algorithms.
Disadvantages:
• The load balancing aspects for Branch and Bound algorithm make it parallelization
difficult.
• The Branch and Bound algorithm is limited to small size network. In the problem
of large networks, where the solution search space grows exponentially with the
scale of the network, the approach becomes relatively prohibitive.
13

More Related Content

PDF
Breadth first search signed
PPTX
Red black trees
PPTX
Astar algorithm
PDF
Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutori...
PPT
Hill climbing
PDF
Recursive algorithms
PPT
Breadth first search and depth first search
PPT
Red black tree
Breadth first search signed
Red black trees
Astar algorithm
Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutori...
Hill climbing
Recursive algorithms
Breadth first search and depth first search
Red black tree

What's hot (20)

PPT
Iterative deepening search
PPT
Chapter3 Search
PPTX
Tree in data structure
PDF
AI3391 ARTIFICIAL INTELLIGENCE Unit I notes.pdf
PDF
Heuristic search-in-artificial-intelligence
PPTX
Fractional knapsack class 13
PPTX
Uninformed search /Blind search in AI
PPTX
A Star Search
PPTX
AVL Tree
PPT
File handling in C++
PPTX
AI_Session 9 Hill climbing algorithm.pptx
PDF
I. Mini-Max Algorithm in AI
PDF
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
PDF
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
PPTX
Multistage graph unit 4 of algorithm.ppt
PPT
Expression evaluation
PPTX
Lecture 14 Heuristic Search-A star algorithm
PPTX
Hashing Technique In Data Structures
PPTX
My lectures circular queue
PPTX
Graph representation
Iterative deepening search
Chapter3 Search
Tree in data structure
AI3391 ARTIFICIAL INTELLIGENCE Unit I notes.pdf
Heuristic search-in-artificial-intelligence
Fractional knapsack class 13
Uninformed search /Blind search in AI
A Star Search
AVL Tree
File handling in C++
AI_Session 9 Hill climbing algorithm.pptx
I. Mini-Max Algorithm in AI
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
Multistage graph unit 4 of algorithm.ppt
Expression evaluation
Lecture 14 Heuristic Search-A star algorithm
Hashing Technique In Data Structures
My lectures circular queue
Graph representation
Ad

Viewers also liked (20)

PPTX
Lecture 09 uninformed problem solving
PDF
AI Lesson 08
PPTX
Lecture 23 alpha beta pruning
PPTX
Alpha beta pruning
PDF
15 predicate
PPT
PPT
Predicate calculus
PPT
Searchadditional2
PDF
17 1 knowledge-based system
PPT
Artificial Intelligence
DOCX
Core java tutorial
PDF
The Unified Modelling Lanage (UML)
PDF
Alphabeta
PDF
Advanced java practical semester 6_computer science
PPT
Heuristic Search
PPT
Lecture 11 Informed Search
ODP
Uml
PPS
Advance Java
PPT
(Radhika) presentation on chapter 2 ai
PPTX
Lecture 30 introduction to logic
Lecture 09 uninformed problem solving
AI Lesson 08
Lecture 23 alpha beta pruning
Alpha beta pruning
15 predicate
Predicate calculus
Searchadditional2
17 1 knowledge-based system
Artificial Intelligence
Core java tutorial
The Unified Modelling Lanage (UML)
Alphabeta
Advanced java practical semester 6_computer science
Heuristic Search
Lecture 11 Informed Search
Uml
Advance Java
(Radhika) presentation on chapter 2 ai
Lecture 30 introduction to logic
Ad

Similar to Lecture 12 Heuristic Searches (20)

PPTX
AI BEST FIRST,A-STAR,AO-STAR SEARCH.pptx
PPTX
A star algorithms
PPT
Uniformed tree searching
PPTX
HEURISTIC SEARCH and other technique.pptx
PPTX
Breadth First Search with example and solutions
PPTX
BFS,DFS,Depth bound,Beam search,Iterative.pptx
DOCX
AI unit-2 lecture notes.docx
PPTX
Best First Search.pptx
PPT
uniformed (also called blind search algo)
PPT
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
PPTX
Introduction of Depth First Search with example
PDF
Analysis of Pathfinding Algorithms
PPTX
Lec 15-graph Searching in data structure and lgorithm.pptx
PPTX
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
PDF
Introduction to Artificial Intelligence with Python, CS50 Approach - GDG on C...
PPTX
General methodin Data Structure for UG.pptx
PPTX
Unit ii-ppt
PDF
problem solve and resolving in ai domain , probloms
PDF
Lec 2 1 informed search
PPTX
Unit 3 Informed Search Strategies.pptx
AI BEST FIRST,A-STAR,AO-STAR SEARCH.pptx
A star algorithms
Uniformed tree searching
HEURISTIC SEARCH and other technique.pptx
Breadth First Search with example and solutions
BFS,DFS,Depth bound,Beam search,Iterative.pptx
AI unit-2 lecture notes.docx
Best First Search.pptx
uniformed (also called blind search algo)
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
Introduction of Depth First Search with example
Analysis of Pathfinding Algorithms
Lec 15-graph Searching in data structure and lgorithm.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
Introduction to Artificial Intelligence with Python, CS50 Approach - GDG on C...
General methodin Data Structure for UG.pptx
Unit ii-ppt
problem solve and resolving in ai domain , probloms
Lec 2 1 informed search
Unit 3 Informed Search Strategies.pptx

More from Hema Kashyap (20)

PPTX
Lecture 29 genetic algorithm-example
PPTX
Lecture 28 genetic algorithm
PPTX
Lecture 27 simulated annealing
PPTX
Lecture 26 local beam search
PPTX
Lecture 25 hill climbing
PPTX
Lecture 24 iterative improvement algorithm
PPTX
Lecture 22 adversarial search
PPTX
Lecture 21 problem reduction search ao star search
PPTX
Lecture 20 problem reduction search
PPTX
Lecture 19 sma star algorithm
PPTX
Lecture 18 simplified memory bound a star algorithm
PPTX
Lecture 17 Iterative Deepening a star algorithm
PPTX
Lecture 16 memory bounded search
PPTX
Lecture 15 monkey banana problem
PPTX
Lecture 13 Criptarithmetic problem
PPTX
Lecture 10 Uninformed Search Techniques conti..
PPTX
Lecture 08 uninformed search techniques
PPTX
Lecture 07 search techniques
PPTX
Lecture 06 production system
PPTX
Lecture 05 problem solving through ai
Lecture 29 genetic algorithm-example
Lecture 28 genetic algorithm
Lecture 27 simulated annealing
Lecture 26 local beam search
Lecture 25 hill climbing
Lecture 24 iterative improvement algorithm
Lecture 22 adversarial search
Lecture 21 problem reduction search ao star search
Lecture 20 problem reduction search
Lecture 19 sma star algorithm
Lecture 18 simplified memory bound a star algorithm
Lecture 17 Iterative Deepening a star algorithm
Lecture 16 memory bounded search
Lecture 15 monkey banana problem
Lecture 13 Criptarithmetic problem
Lecture 10 Uninformed Search Techniques conti..
Lecture 08 uninformed search techniques
Lecture 07 search techniques
Lecture 06 production system
Lecture 05 problem solving through ai

Recently uploaded (20)

PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Categorization of Factors Affecting Classification Algorithms Selection
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
Well-logging-methods_new................
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
Sustainable Sites - Green Building Construction
DOCX
573137875-Attendance-Management-System-original
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Total quality management ppt for engineering students
PPTX
Construction Project Organization Group 2.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Categorization of Factors Affecting Classification Algorithms Selection
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Well-logging-methods_new................
Fundamentals of safety and accident prevention -final (1).pptx
Sustainable Sites - Green Building Construction
573137875-Attendance-Management-System-original
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Total quality management ppt for engineering students
Construction Project Organization Group 2.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
UNIT 4 Total Quality Management .pptx
Safety Seminar civil to be ensured for safe working.
III.4.1.2_The_Space_Environment.p pdffdf
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx

Lecture 12 Heuristic Searches

  • 2. Best First Search • Uniform Cost Search is a special case of the best first search algorithm. The algorithm maintains a priority queue of nodes to be explored. A cost function f(n) is applied to each node. The nodes are put in OPEN in the order of their f values. Nodes with smaller f(n) values are expanded earlier. The generic best first search algorithm is outlined below. 2
  • 3. Concept Step 1: Traverse the root node Step 2: Traverse any neighbour of the root node, that is maintaining a least distance from the root node and insert them in ascending order into the queue. Step 3: Traverse any neighbour of neighbour of the root node, that is maintaining a least distance from the root node and insert them in ascending order into the queue Step 4: This process will continue until we are getting the goal node 3
  • 4. Example Step 1: Consider the node A as our root node. So the first element of the queue is A whish is not our goal node, so remove it from the queue and find its neighbour that are to inserted in ascending order. A Step 2: The neighbours of A are B and C. They will be inserted into the queue in ascending order. B C A(Expanded Node) Step 3: Now B is on the FRONT end of the queue. So calculate the neighbours of B that are maintaining a least distance from the roof. F E D C B(Expanded Node) 4
  • 5. Step 4: Now the node F is on the FRONT end of the queue. But as it has no further children, so remove it from the queue and proceed further. E D C F (Expanded Node) Step 5: Now E is the FRONT end. So the children of E are J and K. Insert them into the queue in ascending order. K J D C E(Expanded Node) Step 6: Now K is on the FRONT end and as it has no further children, so remove it and proceed further J D C K(Expanded Node) Step7: Also, J has no corresponding children. So remove it and proceed further. D C J(Expanded Node) Step 8: Now D is on the FRONT end and calculates the children of D and put it into the queue. I C D(Expanded Node) Step9: Now I is the FRONT node and it has no children. So proceed further after removing this node from the queue. C I(Expanded Node) 5
  • 6. Step 10: Now C is the FRONT node .So calculate the neighbours of C that are to be inserted in ascending order into the queue. G H C(Expanded Node) Step 11: Now remove G from the queue and calculate its neighbour that is to insert in ascending order into the queue. M L H G(Expanded Node) Step12: Now M is the FRONT node of the queue which is our goal node. So stop here and exit. L H M(Expanded Node) 6
  • 7. Advantages • It is more efficient than that of BFS and DFS. • Time complexity of Best first search is much less than Breadth first search. • The Best first search allows us to switch between paths by gaining the benefits of both breadth first and depth first search. Because, depth first is good because a solution can be found without computing all nodes and Breadth first search is good because it does not get trapped in dead ends. Disadvantages • Sometimes, it covers more distance than our consideration. 7
  • 8. Branch and Bound • Branch and Bound is an algorithmic technique which finds the optimal solution by keeping the best solution found so far. • If partial solution can’t improve on the best it is abandoned, by this method the number of nodes which are explored can also be reduced. • It also deals with the optimization problems over a search that can be presented as the leaves of the search tree. • The usual technique for eliminating the sub trees from the search tree is called pruning. • For Branch and Bound algorithm we will use stack data structure. 8
  • 9. Concept Step 1: Traverse the root node. Step 2: Traverse any neighbour of the root node that is maintaining least distance from the root node. Step 3: Traverse any neighbour of the neighbour of the root node that is maintaining least distance from the root node. Step 4: This process will continue until we are getting the goal node. 9
  • 10. Algorithm Step 1: PUSH the root node into the stack. Step 2: If stack is empty, then stop and return failure. Step 3: If the top node of the stack is a goal node, then stop and return success. Step 4: Else POP the node from the stack. Process it and find all its successors. Find out the path containing all its successors as well as predecessors and then PUSH the successors which are belonging to the minimum or shortest path. Step 5: Go to step 5. Step 6: Exit. 10
  • 11. ExampleStep 1: Consider the node A as our root node. Find its successors i.e. B, C, F. Calculate the distance from the root and PUSH them according to least distance. A B: 0+5 = 5 (The cost of A is 0 as it is the starting node) F: 0+9 = 9 C: 0+7 = 7 Here B (5) is the least distance. Step 2: Now the stack will be C F B(Top) A(Expanded) As B is on the top of the stack so calculate the neighbours of B. D: 0+5+4 = 9 E: 0+5+6 = 11 The least distance is D from B. So it will be on the top of the stack. 11
  • 12. Step 3: As the top of the stack is D. So calculate neighbours of D. C F D(Top) B(Expanded) C: 0+5+4+8 = 17 F: 0+5+4+3 = 12 The least distance is F from D and it is our goal node. So stop and return success. Step 4: C F(Top) D(Expanded) Hence the searching path will be A-B -D-F 12
  • 13. Advantages/Disadvantages Advantages: • As it finds the minimum path instead of finding the minimum successor so there should not be any repetition. • The time complexity is less compared to other algorithms. Disadvantages: • The load balancing aspects for Branch and Bound algorithm make it parallelization difficult. • The Branch and Bound algorithm is limited to small size network. In the problem of large networks, where the solution search space grows exponentially with the scale of the network, the approach becomes relatively prohibitive. 13