SlideShare a Scribd company logo
1 of 9
Download to read offline
Search Strategies
Dr. P. Kuppusamy
Prof / CSE
Search strategy
• The important work in search is finding the right search strategy for a problem.
• Evaluate strategies in terms of four criteria:
• Completeness: Strategy guaranteed to find a solution when there is one?
• Time complexity: How long does it take to find a solution?
• Space complexity: how much memory does it need to perform the search?
• Optimality: Does the strategy find the highest-quality solution when there are several
different solutions?
Search strategies
• Uninformed (blind) search - they have no information about the number
of steps or the path cost from the current state to the goal.
• All they can do is distinguish a goal state from a non-goal state.
• Informed (heuristic) search - Strategies that use information.
Breadth-first search
• One simple uninformed search strategy is a breadth-first search.
• The root node is expanded first, then all the nodes generated by the root node are
expanded.
• Then their successors, and so on.
• In general, all the nodes at depth d in the search tree are expanded before the
nodes at depth d + 1.
• BFS can be implemented with a queuing function that puts the newly generated
states at the end of the queue, after all the previously generated states:
Breadth-first search
• BFS is a very systematic strategy because it considers all the paths of length 1
first, then all those of length 2, and so on.
• Figure shows the progress of the search on a simple binary tree.
• If there is a solution, BFS is guaranteed to find it, and if there are several
solutions, BFS will always find the shallowest goal state first.
• BFS is complete, and optimal
Breadth-first search
• Why BFS is not always the strategy of choice?
• Consider the amount of time and memory it takes to complete a search.
• In a hypothetical state space where every state can be expanded to yield b new
states. Let’s take the branching factor of these states (and of the search tree) is b.
• The root of the search tree generates b nodes at the first level, each of which
generates b more nodes, for a total of b2 at the second level.
• Each of these generates b more nodes, yielding b3 nodes at the third level, and so
on.
• Let consider the solution for this problem has a path length of d. Then the
maximum number of nodes expanded before finding a solution is 1 + b + b2 + b3
+ • • • + bd.
• This is the maximum number, but the solution could be found at any point on the
Jth level. In the best case, therefore, the number would be smaller.
• Time complexity O(bd).
Depth First Search (DFS)
• DFS always expands one of the nodes at the deepest level of the tree.
• When the search hits a dead end (a non-goal node with no expansion), then the search go back and expand nodes
at shallower levels.
• This strategy can be implemented with a queuing function that always enters the newly generated states at the
front of the queue.
• Because the expanded node was the deepest, its successors will be even deeper and are therefore now the
deepest. The progress of the search is illustrated below.
Depth First Search (DFS)
• DFS has very modest memory requirements.
• It needs to store only a single path from the root to a leaf node, along with the
remaining unexpanded sibling nodes for each node on the path.
• For a state space with branching factor b and maximum depth d, DFS requires
storage of only bd nodes.
• In contrast, BFS requires bd storage space at depth d.
• DFS would require 12 kilobytes instead of 111 terabytes at depth d=12, a factor of
10 billion times less space. The time complexity for DFS is O(bm).
• Even problems that have many solutions, DFS may actually be faster than BFS,
because it has a good chance of finding a solution after exploring only a small
portion of the whole space.
• BFS would still have to look at all the paths of length d-1 before considering any
of length d. DFS is still O(bm) in the worst case.
Depth First Search (DFS)
• The drawback of DFS is that it can get stuck going down the wrong path.
• Many problems have very deep or even infinite search trees, so DFS will never be
able to recover from an unlucky choice at one of the nodes near the top of the tree.
• The search will always continue downward without backing up, even when a
shallow solution exists.
• Thus, on these problems DFS will either get stuck in an infinite loop and never
return a solution, or it may eventually find a solution path that is longer than the
optimal solution. So, DFS is neither complete nor optimal.
• Because of this, DFS should be avoided for search trees with large or infinite
maximum depths.

More Related Content

What's hot

Neural Networks: Support Vector machines
Neural Networks: Support Vector machinesNeural Networks: Support Vector machines
Neural Networks: Support Vector machinesMostafa G. M. Mostafa
 
Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)Joel P
 
Centralised and distributed database
Centralised and distributed databaseCentralised and distributed database
Centralised and distributed databaseSantosh Singh
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentationramya marichamy
 
Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibraribrar562
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
Decentralization in blockchain
Decentralization in blockchainDecentralization in blockchain
Decentralization in blockchainSaravanan T.M
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision treeKrish_ver2
 
Integration of Sensors & Actuators With Arduino.pptx
Integration of Sensors & Actuators With Arduino.pptxIntegration of Sensors & Actuators With Arduino.pptx
Integration of Sensors & Actuators With Arduino.pptxNShravani1
 
Presentation12 130428221311-phpapp02 (1)
Presentation12 130428221311-phpapp02 (1)Presentation12 130428221311-phpapp02 (1)
Presentation12 130428221311-phpapp02 (1)ARCHANA S
 
Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Mostafa G. M. Mostafa
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmBushra M
 
Transport control protocols for Wireless sensor networks
Transport control protocols for Wireless sensor networksTransport control protocols for Wireless sensor networks
Transport control protocols for Wireless sensor networksRushin Shah
 
Collision resolution.pptx
Collision resolution.pptxCollision resolution.pptx
Collision resolution.pptxVikasNirgude2
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGmuthu181188
 
WSN-Routing Protocols Energy Efficient Routing
WSN-Routing Protocols Energy Efficient RoutingWSN-Routing Protocols Energy Efficient Routing
WSN-Routing Protocols Energy Efficient RoutingArunChokkalingam
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 

What's hot (20)

Neural Networks: Support Vector machines
Neural Networks: Support Vector machinesNeural Networks: Support Vector machines
Neural Networks: Support Vector machines
 
Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)
 
Image compression models
Image compression modelsImage compression models
Image compression models
 
Centralised and distributed database
Centralised and distributed databaseCentralised and distributed database
Centralised and distributed database
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Error Correction And Hamming Code Ibrar
Error Correction And Hamming Code IbrarError Correction And Hamming Code Ibrar
Error Correction And Hamming Code Ibrar
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Decentralization in blockchain
Decentralization in blockchainDecentralization in blockchain
Decentralization in blockchain
 
Distance vector routing
Distance vector routingDistance vector routing
Distance vector routing
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision tree
 
Integration of Sensors & Actuators With Arduino.pptx
Integration of Sensors & Actuators With Arduino.pptxIntegration of Sensors & Actuators With Arduino.pptx
Integration of Sensors & Actuators With Arduino.pptx
 
Floating point arithmetic
Floating point arithmeticFloating point arithmetic
Floating point arithmetic
 
Presentation12 130428221311-phpapp02 (1)
Presentation12 130428221311-phpapp02 (1)Presentation12 130428221311-phpapp02 (1)
Presentation12 130428221311-phpapp02 (1)
 
Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)Neural Networks: Radial Bases Functions (RBF)
Neural Networks: Radial Bases Functions (RBF)
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Transport control protocols for Wireless sensor networks
Transport control protocols for Wireless sensor networksTransport control protocols for Wireless sensor networks
Transport control protocols for Wireless sensor networks
 
Collision resolution.pptx
Collision resolution.pptxCollision resolution.pptx
Collision resolution.pptx
 
SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSING
 
WSN-Routing Protocols Energy Efficient Routing
WSN-Routing Protocols Energy Efficient RoutingWSN-Routing Protocols Energy Efficient Routing
WSN-Routing Protocols Energy Efficient Routing
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 

Similar to Search strategies BFS, DFS

uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptxMUZAMILALI48
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)Nazir Ahmed
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
AI-05 Search Algorithms.pptx
AI-05 Search Algorithms.pptxAI-05 Search Algorithms.pptx
AI-05 Search Algorithms.pptxPankaj Debbarma
 
uninformed search part 2.pptx
uninformed search part 2.pptxuninformed search part 2.pptx
uninformed search part 2.pptxMUZAMILALI48
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)SURBHI SAROHA
 
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
 
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'sHarsha Patel
 
Unit 2 Uninformed Search Strategies.pptx
Unit  2 Uninformed Search Strategies.pptxUnit  2 Uninformed Search Strategies.pptx
Unit 2 Uninformed Search Strategies.pptxDrYogeshDeshmukh1
 
Search Algorithms in AI.pptx
Search Algorithms in AI.pptxSearch Algorithms in AI.pptx
Search Algorithms in AI.pptxDr.Shweta
 

Similar to Search strategies BFS, DFS (20)

uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
 
NEW-II.pptx
NEW-II.pptxNEW-II.pptx
NEW-II.pptx
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
NEW-II.pptx
NEW-II.pptxNEW-II.pptx
NEW-II.pptx
 
2.uninformed search
2.uninformed search2.uninformed search
2.uninformed search
 
AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
 
Search strategies
Search strategiesSearch strategies
Search strategies
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
AI-05 Search Algorithms.pptx
AI-05 Search Algorithms.pptxAI-05 Search Algorithms.pptx
AI-05 Search Algorithms.pptx
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
uninformed search part 2.pptx
uninformed search part 2.pptxuninformed search part 2.pptx
uninformed search part 2.pptx
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)
 
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
 
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
 
Unit 2 Uninformed Search Strategies.pptx
Unit  2 Uninformed Search Strategies.pptxUnit  2 Uninformed Search Strategies.pptx
Unit 2 Uninformed Search Strategies.pptx
 
Search Algorithms in AI.pptx
Search Algorithms in AI.pptxSearch Algorithms in AI.pptx
Search Algorithms in AI.pptx
 
c4.pptx
c4.pptxc4.pptx
c4.pptx
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 

More from Kuppusamy P

Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnnKuppusamy P
 
Image segmentation
Image segmentationImage segmentation
Image segmentationKuppusamy P
 
Image enhancement
Image enhancementImage enhancement
Image enhancementKuppusamy P
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matchingKuppusamy P
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersKuppusamy P
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithmsKuppusamy P
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basicsKuppusamy P
 
Problem solving using Programming
Problem solving using ProgrammingProblem solving using Programming
Problem solving using ProgrammingKuppusamy P
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Kuppusamy P
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or FunctionsKuppusamy P
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statementsKuppusamy P
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Java introduction
Java introductionJava introduction
Java introductionKuppusamy P
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine LearningKuppusamy P
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningKuppusamy P
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationKuppusamy P
 

More from Kuppusamy P (20)

Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnn
 
Deep learning
Deep learningDeep learning
Deep learning
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basics
 
Problem solving using Programming
Problem solving using ProgrammingProblem solving using Programming
Problem solving using Programming
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software
 
Strings in java
Strings in javaStrings in java
Strings in java
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or Functions
 
Java arrays
Java arraysJava arrays
Java arrays
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statements
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Java data types
Java data typesJava data types
Java data types
 
Java introduction
Java introductionJava introduction
Java introduction
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine Learning
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classification
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 

Search strategies BFS, DFS

  • 1. Search Strategies Dr. P. Kuppusamy Prof / CSE
  • 2. Search strategy • The important work in search is finding the right search strategy for a problem. • Evaluate strategies in terms of four criteria: • Completeness: Strategy guaranteed to find a solution when there is one? • Time complexity: How long does it take to find a solution? • Space complexity: how much memory does it need to perform the search? • Optimality: Does the strategy find the highest-quality solution when there are several different solutions?
  • 3. Search strategies • Uninformed (blind) search - they have no information about the number of steps or the path cost from the current state to the goal. • All they can do is distinguish a goal state from a non-goal state. • Informed (heuristic) search - Strategies that use information.
  • 4. Breadth-first search • One simple uninformed search strategy is a breadth-first search. • The root node is expanded first, then all the nodes generated by the root node are expanded. • Then their successors, and so on. • In general, all the nodes at depth d in the search tree are expanded before the nodes at depth d + 1. • BFS can be implemented with a queuing function that puts the newly generated states at the end of the queue, after all the previously generated states:
  • 5. Breadth-first search • BFS is a very systematic strategy because it considers all the paths of length 1 first, then all those of length 2, and so on. • Figure shows the progress of the search on a simple binary tree. • If there is a solution, BFS is guaranteed to find it, and if there are several solutions, BFS will always find the shallowest goal state first. • BFS is complete, and optimal
  • 6. Breadth-first search • Why BFS is not always the strategy of choice? • Consider the amount of time and memory it takes to complete a search. • In a hypothetical state space where every state can be expanded to yield b new states. Let’s take the branching factor of these states (and of the search tree) is b. • The root of the search tree generates b nodes at the first level, each of which generates b more nodes, for a total of b2 at the second level. • Each of these generates b more nodes, yielding b3 nodes at the third level, and so on. • Let consider the solution for this problem has a path length of d. Then the maximum number of nodes expanded before finding a solution is 1 + b + b2 + b3 + • • • + bd. • This is the maximum number, but the solution could be found at any point on the Jth level. In the best case, therefore, the number would be smaller. • Time complexity O(bd).
  • 7. Depth First Search (DFS) • DFS always expands one of the nodes at the deepest level of the tree. • When the search hits a dead end (a non-goal node with no expansion), then the search go back and expand nodes at shallower levels. • This strategy can be implemented with a queuing function that always enters the newly generated states at the front of the queue. • Because the expanded node was the deepest, its successors will be even deeper and are therefore now the deepest. The progress of the search is illustrated below.
  • 8. Depth First Search (DFS) • DFS has very modest memory requirements. • It needs to store only a single path from the root to a leaf node, along with the remaining unexpanded sibling nodes for each node on the path. • For a state space with branching factor b and maximum depth d, DFS requires storage of only bd nodes. • In contrast, BFS requires bd storage space at depth d. • DFS would require 12 kilobytes instead of 111 terabytes at depth d=12, a factor of 10 billion times less space. The time complexity for DFS is O(bm). • Even problems that have many solutions, DFS may actually be faster than BFS, because it has a good chance of finding a solution after exploring only a small portion of the whole space. • BFS would still have to look at all the paths of length d-1 before considering any of length d. DFS is still O(bm) in the worst case.
  • 9. Depth First Search (DFS) • The drawback of DFS is that it can get stuck going down the wrong path. • Many problems have very deep or even infinite search trees, so DFS will never be able to recover from an unlucky choice at one of the nodes near the top of the tree. • The search will always continue downward without backing up, even when a shallow solution exists. • Thus, on these problems DFS will either get stuck in an infinite loop and never return a solution, or it may eventually find a solution path that is longer than the optimal solution. So, DFS is neither complete nor optimal. • Because of this, DFS should be avoided for search trees with large or infinite maximum depths.