SlideShare a Scribd company logo
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

More Related Content

What's hot

A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
Dr. C.V. Suresh Babu
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
Hema Kashyap
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
chandsek666
 
AI Uninformed Search Strategies by Examples
AI Uninformed Search Strategies by ExamplesAI Uninformed Search Strategies by Examples
AI Uninformed Search Strategies by Examples
Ahmed Gad
 
Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithm
Hema Kashyap
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
Tekendra Nath Yogi
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
Syed Ahmed
 
A* algorithm
A* algorithmA* algorithm
A* algorithm
Komal Samdariya
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
4 informed-search
4 informed-search4 informed-search
4 informed-search
Mhd Sb
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
Asst.prof M.Gokilavani
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
Amey Kerkar
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
Dr. C.V. Suresh Babu
 
Ai 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
Mohammed Romi
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by Example
Ahmed Gad
 
Uninformed search
Uninformed searchUninformed search
Uninformed search
Bablu Shofi
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
Tekendra Nath Yogi
 
Informed search
Informed searchInformed search
Informed search
Amit Kumar Rathi
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
Sagacious IT Solution
 
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)
Tajim Md. Niamat Ullah Akhund
 

What's hot (20)

A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
AI Uninformed Search Strategies by Examples
AI Uninformed Search Strategies by ExamplesAI Uninformed Search Strategies by Examples
AI Uninformed Search Strategies by Examples
 
Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithm
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
 
A* algorithm
A* algorithmA* algorithm
A* algorithm
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
4 informed-search
4 informed-search4 informed-search
4 informed-search
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Ai 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by Example
 
Uninformed search
Uninformed searchUninformed search
Uninformed search
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
Informed search
Informed searchInformed search
Informed search
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
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)
 

Similar to 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.pptx
RaviKiranVarma4
 
Searching
SearchingSearching
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
Nazir Ahmed
 
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
 
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
mmpnair0
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
Subash Chandra Pakhrin
 
Search 1
Search 1Search 1
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
Hema Kashyap
 
Ai unit-4
Ai unit-4Ai unit-4
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
Kirti Verma
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
ashetuterefa
 
Search 2
Search 2Search 2
AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docx
CS50Bootcamp
 
informed_search.pdf
informed_search.pdfinformed_search.pdf
informed_search.pdf
SankarTerli
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
Ratnakar Mikkili
 
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
Asst.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 3
Deepak 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 , probloms
SlimAmiri
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
c4.pptx
c4.pptxc4.pptx

Similar to 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)
 
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)
 
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
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
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
 
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 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
 
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)
 
c4.pptx
c4.pptxc4.pptx
c4.pptx
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 

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