SlideShare a Scribd company logo
1 of 37
Artificial Intelligence
Two main types of search
• All search strategies are distinguished by the Order in which nodes
are expanded
1. Uninformed search methods (Blind search) have access only to the
problem definition.
• Breadth-first search
• Uniform-cost search
• Depth-first search
• Iterative deepening search
• Bidirectional search
2. Informed search methods may have access to a heuristic function
h(n) that estimate the cost of a solution from n.
• Greedy best-first search
• A* search
• Recursive best-first search (RBFS) search
Uninformed Search
• Sometimes we may not get much relevant information
to solve a problem.
• Suppose we lost our car key and we are not able to
recall where we left, we have to search for the key with
some information such as in which places we used to
place it. It may be our pant pocket or may be the table
drawer. If it is not there then we have to search the
whole house to get it. The best solution would be to
search in the places from the table to the wardrobe.
Here we need to search blindly with less clue.
• This type of search is called uninformed search or blind
search.
Uninformed Search and Exploration
 Blind search – BFS, DFS, uniform cost
 no notion concept of the “right direction”
 can only recognize goal once it’s achieved
Informed Search
• We can solve the problem in an efficient manner
if we have relevant information, clues or hints.
The clues that help solve the problem constitute
heuristic information.
• Informed search is also called heuristic search.
• Instead of searching one path or many paths just
like that informed search uses the given heuristic
information to decide whether or not to explore
the current state further.
Informed Search
• Add domain-specific information to select the best
path along which to continue searching
• Define a heuristic function, h(n), that estimates the
“goodness” of a node n.
• Specifically, h(n) = estimated cost (or distance) of
minimal cost path from n to a goal state.
• The heuristic function is an estimate, based on
domain-specific information that is computable from
the current state description, of how close we are to
a goal
Breadth-first search
• Breadth first search (BFS), as the name implies,
searches from the initial state breadth-wise.
• That is it searches all the states in the tree level
by level.
• Only after exploring all the states in one level it
will jump to the next level.
• Once the solution is found the search stops.
• The breadth first search is guaranteed to find the
solution if one exists.
Breadth-first search
• Expand shallowest unexpanded node
• Implementation:
Breadth-first search
• Expand shallowest unexpanded node
• Implementation:
Breadth-first search
• Expand shallowest unexpanded node
• Implementation:
Breadth-first search
• Expand shallowest unexpanded node
Breadth-first searching
• A breadth-first search (BFS)
explores nodes nearest the
root before exploring nodes
further away
• For example, after searching
A, then B, then C, the search
proceeds with D, E, F, G
• Node are explored in the
order A B C D E F G H I J K L
M N O P Q
• J will be found before NL M N O P
G
Q
H JI K
FED
B C
A
Breadth-first search algorithm
Nodes are lining up to be visited in open.
closed keeps track of all the nodes visited already.
A trace of
breadth-first algorithm
|
| |
||
| | |
| | |
||||
Items between red bars are
siblings.
B is not the goal.
Put his children onto the queue.
Put him in closed. He is done.
goal is reached or open is empty.
Properties of breadth-first search
• Complete? Yes (if b is finite)
• Time? 1+b+b2+b3+… +bd + b(bd-1) = O(bd+1)
• Space? O(bd+1) (keeps every node in memory)
• Optimal? Yes (if cost = 1 per step)
• Space is the bigger problem (more than time)
Depth-first search
• Explore only one branch deeper till the solution is
found or there is no new state to explore and
then start searching the adjacent level.
• This technique is called depth first searh (DFS).
• By chance the solution exists in the first branch
then depth first search can find the solution
quickly.
• If the solution exists in some other branches
farther away, there won't be much difference
between depth first search and breadth first
search
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first search
• Expand deepest unexpanded node
•
• Implementation:
Depth-first searching
• A depth-first search (DFS)
explores a path all the way to
a leaf before backtracking and
exploring another path
• For example, after searching
A, then B, then D, the search
backtracks and tries another
path from B
• Node are explored in the
order A B D E H L M N I
O P C F G J K Q
• N will be found before J
L M N O P
G
Q
H JI K
FED
B C
A
The depth-first search algorithm
This is the only difference between
depth-first and breadth-first.
A trace of
depth-first algorithm
top of stack
Snap shot at iteration 6
frontier
visited
Properties of depth-first search
• Complete? No: fails in infinite-depth spaces, spaces with loops
– Modify to avoid repeated states along path
–
 complete in finite spaces
• Time? O(bm): terrible if m is much larger than d
– but if solutions are dense, may be much faster than breadth-first
–
• Space? O(bm), i.e., linear space!
•
• Optimal? No
•
Search sequences of depth-first and breadth-first
Breadth first: A, B, C, …
Depth first: 1, 2, 3, …
Comparing the ordering of search sequences
• Determine the order of nodes (states) to be examined
• Breadth-first search
– When a state is examined, all of its children are
examined, one after another
– Explore the search space in a level-by-level fashion
• Depth-first search
– When a state is examined, all of its children and
their descendants are examined before any of its
siblings
– Go deeper into the search space where possible
Breadth-first search of the 8-puzzle
 
Cannot move
blank downward


Depth-first search of 8-puzzle with a depth bound of 5
Breadth-first
took
46 nodes.

More Related Content

Similar to Artificial intelligence(05)

Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxCS50Bootcamp
 
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
 
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.pptmmpnair0
 
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)ssuser2a76b5
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search techniqueKapil Dahal
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligenceananth
 

Similar to Artificial intelligence(05) (20)

Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Search 1
Search 1Search 1
Search 1
 
NEW-II.pptx
NEW-II.pptxNEW-II.pptx
NEW-II.pptx
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
abhishek ppt.pptx
abhishek ppt.pptxabhishek ppt.pptx
abhishek ppt.pptx
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docx
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
 
Artificial intelligence(06)
Artificial intelligence(06)Artificial intelligence(06)
Artificial intelligence(06)
 
Search strategies
Search strategiesSearch strategies
Search strategies
 
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
 
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
Searching
SearchingSearching
Searching
 
AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
 
NEW-II.pptx
NEW-II.pptxNEW-II.pptx
NEW-II.pptx
 

More from Nazir Ahmed

Data structures final lecture 1
Data structures final  lecture 1Data structures final  lecture 1
Data structures final lecture 1Nazir Ahmed
 
Data structures lecture 04
Data structures  lecture 04Data structures  lecture 04
Data structures lecture 04Nazir Ahmed
 
Control unit design(1)
Control unit design(1)Control unit design(1)
Control unit design(1)Nazir Ahmed
 
Computer architecture mcq (2)
Computer architecture mcq (2)Computer architecture mcq (2)
Computer architecture mcq (2)Nazir Ahmed
 
Complete binary tree and heap
Complete binary tree and heapComplete binary tree and heap
Complete binary tree and heapNazir Ahmed
 
Clamper clipper(10)
Clamper clipper(10)Clamper clipper(10)
Clamper clipper(10)Nazir Ahmed
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sqlNazir Ahmed
 
Chapter # 12 er modeling
Chapter # 12 er modelingChapter # 12 er modeling
Chapter # 12 er modelingNazir Ahmed
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-schedulingNazir Ahmed
 

More from Nazir Ahmed (20)

Data structures final lecture 1
Data structures final  lecture 1Data structures final  lecture 1
Data structures final lecture 1
 
Data structures lecture 04
Data structures  lecture 04Data structures  lecture 04
Data structures lecture 04
 
Data structure
Data structureData structure
Data structure
 
Cover letter
Cover letterCover letter
Cover letter
 
Control unit design(1)
Control unit design(1)Control unit design(1)
Control unit design(1)
 
Computer architecture mcq (2)
Computer architecture mcq (2)Computer architecture mcq (2)
Computer architecture mcq (2)
 
Complete binary tree and heap
Complete binary tree and heapComplete binary tree and heap
Complete binary tree and heap
 
Clamper clipper(10)
Clamper clipper(10)Clamper clipper(10)
Clamper clipper(10)
 
Cisc mc68000
Cisc mc68000Cisc mc68000
Cisc mc68000
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sql
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
Chapter # 12 er modeling
Chapter # 12 er modelingChapter # 12 er modeling
Chapter # 12 er modeling
 
Chapeter 2
Chapeter 2Chapeter 2
Chapeter 2
 
Ch7 1 v1
Ch7 1 v1Ch7 1 v1
Ch7 1 v1
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Ch04 threads
Ch04 threadsCh04 threads
Ch04 threads
 
Ch03 processes
Ch03 processesCh03 processes
Ch03 processes
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 

Artificial intelligence(05)

  • 2. Two main types of search • All search strategies are distinguished by the Order in which nodes are expanded 1. Uninformed search methods (Blind search) have access only to the problem definition. • Breadth-first search • Uniform-cost search • Depth-first search • Iterative deepening search • Bidirectional search 2. Informed search methods may have access to a heuristic function h(n) that estimate the cost of a solution from n. • Greedy best-first search • A* search • Recursive best-first search (RBFS) search
  • 3. Uninformed Search • Sometimes we may not get much relevant information to solve a problem. • Suppose we lost our car key and we are not able to recall where we left, we have to search for the key with some information such as in which places we used to place it. It may be our pant pocket or may be the table drawer. If it is not there then we have to search the whole house to get it. The best solution would be to search in the places from the table to the wardrobe. Here we need to search blindly with less clue. • This type of search is called uninformed search or blind search.
  • 4. Uninformed Search and Exploration  Blind search – BFS, DFS, uniform cost  no notion concept of the “right direction”  can only recognize goal once it’s achieved
  • 5. Informed Search • We can solve the problem in an efficient manner if we have relevant information, clues or hints. The clues that help solve the problem constitute heuristic information. • Informed search is also called heuristic search. • Instead of searching one path or many paths just like that informed search uses the given heuristic information to decide whether or not to explore the current state further.
  • 6. Informed Search • Add domain-specific information to select the best path along which to continue searching • Define a heuristic function, h(n), that estimates the “goodness” of a node n. • Specifically, h(n) = estimated cost (or distance) of minimal cost path from n to a goal state. • The heuristic function is an estimate, based on domain-specific information that is computable from the current state description, of how close we are to a goal
  • 7. Breadth-first search • Breadth first search (BFS), as the name implies, searches from the initial state breadth-wise. • That is it searches all the states in the tree level by level. • Only after exploring all the states in one level it will jump to the next level. • Once the solution is found the search stops. • The breadth first search is guaranteed to find the solution if one exists.
  • 8. Breadth-first search • Expand shallowest unexpanded node • Implementation:
  • 9. Breadth-first search • Expand shallowest unexpanded node • Implementation:
  • 10. Breadth-first search • Expand shallowest unexpanded node • Implementation:
  • 11. Breadth-first search • Expand shallowest unexpanded node
  • 12. Breadth-first searching • A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away • For example, after searching A, then B, then C, the search proceeds with D, E, F, G • Node are explored in the order A B C D E F G H I J K L M N O P Q • J will be found before NL M N O P G Q H JI K FED B C A
  • 13. Breadth-first search algorithm Nodes are lining up to be visited in open. closed keeps track of all the nodes visited already.
  • 14. A trace of breadth-first algorithm | | | || | | | | | | |||| Items between red bars are siblings. B is not the goal. Put his children onto the queue. Put him in closed. He is done. goal is reached or open is empty.
  • 15. Properties of breadth-first search • Complete? Yes (if b is finite) • Time? 1+b+b2+b3+… +bd + b(bd-1) = O(bd+1) • Space? O(bd+1) (keeps every node in memory) • Optimal? Yes (if cost = 1 per step) • Space is the bigger problem (more than time)
  • 16. Depth-first search • Explore only one branch deeper till the solution is found or there is no new state to explore and then start searching the adjacent level. • This technique is called depth first searh (DFS). • By chance the solution exists in the first branch then depth first search can find the solution quickly. • If the solution exists in some other branches farther away, there won't be much difference between depth first search and breadth first search
  • 17. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 18. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 19. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 20. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 21. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 22. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 23. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 24. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 25. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 26. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 27. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 28. Depth-first search • Expand deepest unexpanded node • • Implementation:
  • 29. Depth-first searching • A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path • For example, after searching A, then B, then D, the search backtracks and tries another path from B • Node are explored in the order A B D E H L M N I O P C F G J K Q • N will be found before J L M N O P G Q H JI K FED B C A
  • 30. The depth-first search algorithm This is the only difference between depth-first and breadth-first.
  • 31. A trace of depth-first algorithm top of stack
  • 32. Snap shot at iteration 6 frontier visited
  • 33. Properties of depth-first search • Complete? No: fails in infinite-depth spaces, spaces with loops – Modify to avoid repeated states along path –  complete in finite spaces • Time? O(bm): terrible if m is much larger than d – but if solutions are dense, may be much faster than breadth-first – • Space? O(bm), i.e., linear space! • • Optimal? No •
  • 34. Search sequences of depth-first and breadth-first Breadth first: A, B, C, … Depth first: 1, 2, 3, …
  • 35. Comparing the ordering of search sequences • Determine the order of nodes (states) to be examined • Breadth-first search – When a state is examined, all of its children are examined, one after another – Explore the search space in a level-by-level fashion • Depth-first search – When a state is examined, all of its children and their descendants are examined before any of its siblings – Go deeper into the search space where possible
  • 36. Breadth-first search of the 8-puzzle   Cannot move blank downward  
  • 37. Depth-first search of 8-puzzle with a depth bound of 5 Breadth-first took 46 nodes.