SlideShare une entreprise Scribd logo
1  sur  20
Uniformed Tree
Searching
Prepared by
Aya Elshiwi
Supervisor
Dr.Eman Eldaydamony
Tree searching
A
B
D

C
E

F

H
L

M

I
N

O

G
J

P

K
Q

• A tree search starts at the
root and explores nodes
from there, looking for a
goal node (a node that
satisfies certain conditions,
depending on the problem)
• For some problems, any goal
node is acceptable (N or J);
for other problems, you
want a minimum-depth goal
node, that is, a goal node
nearest the root (only J)
Goal nodes
2
Search Algorithms
Uninformed vs. informed
Search algorithms differ by how they pick which node to
expand.
• Uninformed search Algorithms

– In making this decision, these look only at the structure of the
search tree and not at the states inside the nodes.
– Also known as “blind search”.
– Uninformed search methods: Breadth-first, depth-first, depthlimited, uniform-cost, depth-first iterative deepening,
bidirectional.

• Informed search Algorithms

– In making this decision , these look at the states inside the
nodes.
– Also known as “heuristic search”.
– Informed search methods: Hill climbing, best-first, greedy
search, beam search, A, A*

3
Example
Uniformed (blind) search

Informed (heuristic) search

4
Evaluating Search Strategies
Strategies are evaluated along the following
dimensions:
– Completeness: Does it always find a solution if
one exists?
– Time complexity: How long does it take to find
a solution ?
– Space complexity: How much memory is
needed to perform the search?
– Optimality: Does the strategy find the optimal
solution?

5
Uniformed search Algorithms
• Depth First Search [DFS]
• Breadth First Search [BFS]
• Uniform Cost Search [UCS]

6
Depth-first searching
• A depth-first search (DFS)
explores a path all the way to a
leaf before backtracking and
exploring another path.

Animated Graphic

• The search proceeds immediately
to the deepest level of the search
tree, where the nodes have no
successors . As those nodes are
expanded , they are dropped
from the Frontier [stack] ,so then
the search “backs up” to the
deepest next node that still has
unexplored successors .
• Use Stack data structure [FILO] as
a frontier .
7
How to do depth-first searching
A

Example
B

Algorithm
Put the root node on a stack;
while (stack is not empty) {
remove a node from the
stack;
if (node is a goal node)
return success;
put all children of node onto
the stack;
}
return failure;

D

C
E

F

H
L

M

I
N

O

G
J

P

K
Q

Animated Graphic
•
•
•

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
OPCFGJKQ
N will be found before J
8
Example

9
Properties of Depth First Algorithm
b( branching factor) : Maximum number of successors of any
node.
m: maximal depth of a leaf node
•
•
•
•
•

Number of nodes generated (worst case):
1 + b + b2 + … + bm = O(bm)
Complete: only for finite search tree
Optimal : Not optimal
Time complexity: O(bm)
Space complexity : O(bm) [or O(m)]

10
Breadth-first searching
• A breadth-first search (BFS) is
a simple strategy in which the
root node is expanded first ,
then all the successors of the
root node , then their
successors.
•

Animated Graphic

In general , all the nodes are
expanded at a given depth in
the search tree before any
nodes at the next level are
expanded.

• Use a queue data
structure [FIFO].
11
How to do breadth-first searching
A

Algorithm
•
•

•

•

B

Enqueue the root node
Dequeue a node and examine it

D

– If the element sought is found in
this node, quit the search and
return a result.
– Otherwise enqueue any successors
(the direct child nodes) that have
not yet been discovered.

If the queue is empty, every node
on the graph has been examined
– quit the search and return "not
found".
If the queue is not empty, repeat
from Step 2.

C
E

F

H
L

M

I
N

O

G
J

P

K
Q

Animated Graphic

• 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 O12 Q
P
Properties of breadth-first search
b: branching factor
d: depth of shallowest goal node
Total number of nodes generated is:
1+b+b2+b3+… … + bd = O(bd )
• Complete Yes (if b is finite)
• Time 1+b+b2+b3+… … + bd + b(bd -1) = O(bd+1)
Because the whole layer of nodes at depth d would be
expanded before detecting the goal .
• Space O(bd) (keeps every node in memory)
• Optimal if all operators have the same cost.
13
Depth- vs. breadth-first searching
• When a breadth-first search succeeds, it finds a
minimum-depth (nearest the root) goal node.
• When a depth-first search succeeds, the found
goal node is not necessarily minimum depth.
• For a large tree, breadth-first search memory
requirements may be excessive.
• For a large tree, a depth-first search may take an
excessively long time to find even a very nearby
goal node.
14
Uniform cost search
•

Find the least-cost goal .

•

The search begins at the root node. The
search continues by visiting the next node
which has the least total cost from the
root. Nodes are visited in this manner
until a goal state is reached.

•

Each node has a path cost from start (=
sum of edge costs along the path). Expand
the least cost node first.

•

Equivalent to breadth-first if step costs all
equal

•

Use a priority queue (ordered by path
cost) instead of a normal queue .

Animated Graph

15
Pesudocode
procedure UniformCostSearch(Graph, root, goal)
node := root, cost = 0
frontier := priority queue containing node only
explored := empty set
Do
if frontier is empty
return failure
node := frontier.pop()
if node is goal
return solution
explored.add(node)
for each of node's neighbors n
if n is not in explored
if n is not in frontier
frontier.add(n)
else if n is in frontier with higher cost
replace existing node with n
16
How to do Uniform Cost Search
Algorithm
if
- Frontier : empty >Return fail
else
- Add node to frontier.
- Check: node (goal)>solution
- Add node to explored.
- Neighbor s: if not explored
>add to frontier
- Else :if was with higher cost
replace it .

Example

Solution
Explored : A D B E F C
path: A to D to F to G
Cost = 8
17
Properties of uniform cost search
- Equivalent to breadth-first if step costs all equal.
• Complete
Yes .assuming that operator costs are nonnegative (the cost of
path never decreases)
• Optimal
Yes. Returns the least-cost path.

18
Reference

• Solving problems by searching :
http://www.pearsonhighered.com/samplechapter/0136042597
• Depth-First search :
http://en.wikipedia.org/wiki/Depth-first_search
• Breadth-First search:
http://en.wikipedia.org/wiki/Breadth-first_search
• Uniform cost search :
http://en.wikipedia.org/wiki/Uniform-cost_search
• Depth First & Breadth First:
https://www.youtube.com/watch?v=zLZhSSXAwxI
19
Questions?

20

Contenu connexe

Tendances

Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
Evaluating hypothesis
Evaluating  hypothesisEvaluating  hypothesis
Evaluating hypothesisswapnac12
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceJay Nagar
 
6 games
6 games6 games
6 gamesMhd Sb
 
Types of environment in Artificial Intelligence
Types of environment in Artificial IntelligenceTypes of environment in Artificial Intelligence
Types of environment in Artificial IntelligenceNoman Ullah Khan
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AIvikas dhakane
 
State Space Search in ai
State Space Search in aiState Space Search in ai
State Space Search in aivikas dhakane
 
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...RahulSharma4566
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and LiftingMegha Sharma
 
Uncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceUncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceExperfy
 
Optimization in Deep Learning
Optimization in Deep LearningOptimization in Deep Learning
Optimization in Deep LearningYan Xu
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
Genetic Algorithm in Artificial Intelligence
Genetic Algorithm in Artificial IntelligenceGenetic Algorithm in Artificial Intelligence
Genetic Algorithm in Artificial IntelligenceSinbad Konick
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rulesswapnac12
 

Tendances (20)

Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
Evaluating hypothesis
Evaluating  hypothesisEvaluating  hypothesis
Evaluating hypothesis
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
6 games
6 games6 games
6 games
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Types of environment in Artificial Intelligence
Types of environment in Artificial IntelligenceTypes of environment in Artificial Intelligence
Types of environment in Artificial Intelligence
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AI
 
State Space Search in ai
State Space Search in aiState Space Search in ai
State Space Search in ai
 
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
Heuristic Search in Artificial Intelligence | Heuristic Function in AI | Admi...
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and Lifting
 
Uncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial IntelligenceUncertain Knowledge and Reasoning in Artificial Intelligence
Uncertain Knowledge and Reasoning in Artificial Intelligence
 
Optimization in Deep Learning
Optimization in Deep LearningOptimization in Deep Learning
Optimization in Deep Learning
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
A Star Search
A Star SearchA Star Search
A Star Search
 
Genetic Algorithm in Artificial Intelligence
Genetic Algorithm in Artificial IntelligenceGenetic Algorithm in Artificial Intelligence
Genetic Algorithm in Artificial Intelligence
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
 
5 csp
5 csp5 csp
5 csp
 
AI Lecture 4 (informed search and exploration)
AI Lecture 4 (informed search and exploration)AI Lecture 4 (informed search and exploration)
AI Lecture 4 (informed search and exploration)
 

Similaire à Uniformed tree searching

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
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)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
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesHema Kashyap
 
AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxCS50Bootcamp
 
informed_search.pdf
informed_search.pdfinformed_search.pdf
informed_search.pdfSankarTerli
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxRatnakar Mikkili
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesHema Kashyap
 
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAsst.prof M.Gokilavani
 
Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Deepak John
 
problem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , problomsproblem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , problomsSlimAmiri
 

Similaire à Uniformed tree searching (20)

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
 
Searching
SearchingSearching
Searching
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
 
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)
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
Search 1
Search 1Search 1
Search 1
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Search 2
Search 2Search 2
Search 2
 
AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docx
 
informed_search.pdf
informed_search.pdfinformed_search.pdf
informed_search.pdf
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
 
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
 
Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Analysis and design of algorithms part 3
Analysis and design of algorithms part 3
 
problem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , problomsproblem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , probloms
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 

Dernier

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Dernier (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Uniformed tree searching

  • 1. Uniformed Tree Searching Prepared by Aya Elshiwi Supervisor Dr.Eman Eldaydamony
  • 2. Tree searching A B D C E F H L M I N O G J P K Q • A tree search starts at the root and explores nodes from there, looking for a goal node (a node that satisfies certain conditions, depending on the problem) • For some problems, any goal node is acceptable (N or J); for other problems, you want a minimum-depth goal node, that is, a goal node nearest the root (only J) Goal nodes 2
  • 3. Search Algorithms Uninformed vs. informed Search algorithms differ by how they pick which node to expand. • Uninformed search Algorithms – In making this decision, these look only at the structure of the search tree and not at the states inside the nodes. – Also known as “blind search”. – Uninformed search methods: Breadth-first, depth-first, depthlimited, uniform-cost, depth-first iterative deepening, bidirectional. • Informed search Algorithms – In making this decision , these look at the states inside the nodes. – Also known as “heuristic search”. – Informed search methods: Hill climbing, best-first, greedy search, beam search, A, A* 3
  • 5. Evaluating Search Strategies Strategies are evaluated along the following dimensions: – Completeness: Does it always find a solution if one exists? – Time complexity: How long does it take to find a solution ? – Space complexity: How much memory is needed to perform the search? – Optimality: Does the strategy find the optimal solution? 5
  • 6. Uniformed search Algorithms • Depth First Search [DFS] • Breadth First Search [BFS] • Uniform Cost Search [UCS] 6
  • 7. Depth-first searching • A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path. Animated Graphic • The search proceeds immediately to the deepest level of the search tree, where the nodes have no successors . As those nodes are expanded , they are dropped from the Frontier [stack] ,so then the search “backs up” to the deepest next node that still has unexplored successors . • Use Stack data structure [FILO] as a frontier . 7
  • 8. How to do depth-first searching A Example B Algorithm Put the root node on a stack; while (stack is not empty) { remove a node from the stack; if (node is a goal node) return success; put all children of node onto the stack; } return failure; D C E F H L M I N O G J P K Q Animated Graphic • • • 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 OPCFGJKQ N will be found before J 8
  • 10. Properties of Depth First Algorithm b( branching factor) : Maximum number of successors of any node. m: maximal depth of a leaf node • • • • • Number of nodes generated (worst case): 1 + b + b2 + … + bm = O(bm) Complete: only for finite search tree Optimal : Not optimal Time complexity: O(bm) Space complexity : O(bm) [or O(m)] 10
  • 11. Breadth-first searching • A breadth-first search (BFS) is a simple strategy in which the root node is expanded first , then all the successors of the root node , then their successors. • Animated Graphic In general , all the nodes are expanded at a given depth in the search tree before any nodes at the next level are expanded. • Use a queue data structure [FIFO]. 11
  • 12. How to do breadth-first searching A Algorithm • • • • B Enqueue the root node Dequeue a node and examine it D – If the element sought is found in this node, quit the search and return a result. – Otherwise enqueue any successors (the direct child nodes) that have not yet been discovered. If the queue is empty, every node on the graph has been examined – quit the search and return "not found". If the queue is not empty, repeat from Step 2. C E F H L M I N O G J P K Q Animated Graphic • 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 O12 Q P
  • 13. Properties of breadth-first search b: branching factor d: depth of shallowest goal node Total number of nodes generated is: 1+b+b2+b3+… … + bd = O(bd ) • Complete Yes (if b is finite) • Time 1+b+b2+b3+… … + bd + b(bd -1) = O(bd+1) Because the whole layer of nodes at depth d would be expanded before detecting the goal . • Space O(bd) (keeps every node in memory) • Optimal if all operators have the same cost. 13
  • 14. Depth- vs. breadth-first searching • When a breadth-first search succeeds, it finds a minimum-depth (nearest the root) goal node. • When a depth-first search succeeds, the found goal node is not necessarily minimum depth. • For a large tree, breadth-first search memory requirements may be excessive. • For a large tree, a depth-first search may take an excessively long time to find even a very nearby goal node. 14
  • 15. Uniform cost search • Find the least-cost goal . • The search begins at the root node. The search continues by visiting the next node which has the least total cost from the root. Nodes are visited in this manner until a goal state is reached. • Each node has a path cost from start (= sum of edge costs along the path). Expand the least cost node first. • Equivalent to breadth-first if step costs all equal • Use a priority queue (ordered by path cost) instead of a normal queue . Animated Graph 15
  • 16. Pesudocode procedure UniformCostSearch(Graph, root, goal) node := root, cost = 0 frontier := priority queue containing node only explored := empty set Do if frontier is empty return failure node := frontier.pop() if node is goal return solution explored.add(node) for each of node's neighbors n if n is not in explored if n is not in frontier frontier.add(n) else if n is in frontier with higher cost replace existing node with n 16
  • 17. How to do Uniform Cost Search Algorithm if - Frontier : empty >Return fail else - Add node to frontier. - Check: node (goal)>solution - Add node to explored. - Neighbor s: if not explored >add to frontier - Else :if was with higher cost replace it . Example Solution Explored : A D B E F C path: A to D to F to G Cost = 8 17
  • 18. Properties of uniform cost search - Equivalent to breadth-first if step costs all equal. • Complete Yes .assuming that operator costs are nonnegative (the cost of path never decreases) • Optimal Yes. Returns the least-cost path. 18
  • 19. Reference • Solving problems by searching : http://www.pearsonhighered.com/samplechapter/0136042597 • Depth-First search : http://en.wikipedia.org/wiki/Depth-first_search • Breadth-First search: http://en.wikipedia.org/wiki/Breadth-first_search • Uniform cost search : http://en.wikipedia.org/wiki/Uniform-cost_search • Depth First & Breadth First: https://www.youtube.com/watch?v=zLZhSSXAwxI 19