SlideShare a Scribd company logo
Uninformed Search
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Problem Solving
• Two ways to solve the problem are
– Search based approaches
– Knowledge based approaches
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Search based approaches
Used some representation of problem domain, than
simulate what would happen in domain as a consequence
of action and try to find the solution
Simple trial -and -error approach can be applied to solve
the problem
In these approaches, prior knowledge of the problem
domain is not required
Can be easily applied to any real world problem
Use some knowledge to represent the domain, however,
the solution may or may not use domain knowledge
– Uninformed search
» Actions are well defined, does not use any domain knowledge to
choose most likely candidate
– Informed search
» Attempt to choose most likely candidate based on domain
knowledge
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Knowledge based approach
• Can be of two types
– Memory or case based approach
• These approaches used some solved problem and then
apply their solution to solve new unknown problem.
• Use a database of that contains pair of problem and solution
• Ex: integration solving
– Rule based approach
• Use many solved problems and domain expert to infer the
knowledge
• Store knowledge in form of rules
• Apply rules to solve new problem
• Ex: Expert System
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Problem Solving
Using
Uniformed search
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Uninformed search
• These strategies use only the information
available in the problem definition.
– Generate and Test
– Breadth-first search
– Depth-first search
– Depth-limited Iterative deepening search
Dr. Amit Kumar, Dept of CSE, JUET, Guna
State space
• Formulate a problem as a state space by showing the
legal problem states, the legal operators/action, and
the initial and goal states .
• A state is defined by the specification of the values of
all attributes of interest in the world
• An operator changes one state into the other; it has a
precondition which is the value of certain attributes
prior to the application of the operator, and a set of
effects, which are the attributes altered by the
operator
• The initial state is where you start
• The goal state is the partial description of the solution
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Generate and Test
•The algorithm always picks the first node from state space
for test.
•If the node contains a goal state, the success is returned.
• Otherwise, the successor of the node is generated and
same process is repeated
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Generate and Test: Simple Search-1
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Cycle formation in Simple Search-1
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Generate and Test: Simple Search-2
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Cycle formation in Simple Search-2
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Generate and Test:
with path information
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Few more refinements
• Always pick the first node in the list
• There are two choices regarding addition of
successor nodes to the open
– Add successor nodes to the head of open list
– Add successor nodes to the tail of open list
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Breadth First Search (BFS)
• It expands all the states one step away from the initial state, then
expands all states two steps from initial state, then three steps etc.,
until a goal state is reached.
• It expands all nodes at a given depth before expanding any nodes at
a greater depth.
• All nodes at the same level are searched before going to the next
level down.
• We can implement it by using two lists called OPEN and CLOSED.
The OPEN list contains those states that are to be expanded and
CLOSED list keeps track of states already expanded. Here OPEN list
is used as a queue.
• BFS is effective when the search tree has a low branching factor.
Dr. Amit Kumar, Dept of CSE, JUET, Guna
BFS illustration
State Space Graph State-Space tree
Dr. Amit Kumar, Dept of CSE, JUET, Guna
BFS illustration
Step 1: Initially open contains only one node
corresponding to the source state A.
Step 2: A is removed from open. The node is
expanded, and its children B and C are
generated. They are placed at the back of
open.
Open = A
Close = {}
Open = BC
Close = {A}
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Step 3: Node B is removed from open and is
expanded. Its children D, E are generated and
put at the back of open.
Step 4: Node C is removed from open and
is expanded. Its children D and G are
added to the back of open.
Open = C,D,E
Close = AB
Open = D,E,D,G
Close = A,B,C
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Step 5: Node D is removed from open. Its
children C and F are generated and added to
the back of open.
Step 6: Node E is removed from open. It
has no children
Open = E, D,G,C,F
Close = A,B,C,D
Open = D,G,C,F
Close = A,B,C,D,E
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Step 7: D is expanded, B and F are put in OPEN. Step 8: G is selected for expansion. It is
found to be a goal node. So the algorithm
returns the path A C G by following the
parent pointers of the node
corresponding to G. The algorithm
terminates.
Open = C,F,B,F
Close = A,B,C,D,E,G
Open = G,C,F,B,F
Close = A,B,C,D,E,D
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Algorithm (BFS)
Input: Two states in the state space START and GOAL
Local Variables: OPEN, CLOSED, STATE-X, SUCCS
Output: Yes or No
Method:
Initially OPEN list contains a START node and CLOSED list is empty;
Found = false;
While (OPEN ≠empty and Found = false)
Do {
Remove the first state from OPEN and call it STATE-X;
Put STATE-X in the front of CLOSED list;
If STATE-X = GOAL
then Found = true
Dr. Amit Kumar, Dept of CSE, JUET, Guna
else
{
-perform EXPAND operation on STATE-X,
producing a list of SUCCESSORS;
-Remove from successors those states, if any,
that are in the CLOSED list;
-Append SUCCESSORS at the end of the OPEN
list/*queue*/
}
} /* end while */
If Found = true
then return Yes
else
return No and Stop
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Breadth First Search
• Advantages of Breadth First Search
– Finds the path of minimal length to the goal.
– BFS can work even in trees that are infinitely deep.
• Disadvantages of Breadth First Search
– Requires the generation and storage of a tree
whose size is exponential
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Depth-First Search
• In depth-first search we go as far down as possible into
the search tree / graph before backing up and trying
alternatives.
• It works by always generating a descendent of the most
recently expanded node until some depth cut off is
reached and then backtracks to next most recently
expanded node and generates one of its descendants.
• So only path of nodes from the initial node to the
current node is stored in order to execute the algorithm.
Dr. Amit Kumar, Dept of CSE, JUET, Guna
• Again use two lists called OPEN and
CLOSED with the same conventions explained
earlier.
• Here OPEN list is used as a stack.
• If we discover that first element of OPEN is
the Goal state, then search terminates
successfully.
Dr. Amit Kumar, Dept of CSE, JUET, Guna
DFS illustration
State Space Graph State-Space tree
Dr. Amit Kumar, Dept of CSE, JUET, Guna
DFS illustration
Step 1: Initially open contains only one node
corresponding to the source state A.
Step 2: A is removed from open. The
node A is expanded, and its children B
and C are generated. They are placed at
the front of open.
Open = A
Close = {}
Open = BC
Close = {A}
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Step 3: Node B is removed from open and is
expanded. Its children D, E are generated and
put at the front of open.
Step 4: Node D is removed from open and
is expanded. Its children C and F are
added to the front of open.
Open = D,E,C
Close = AB
Open = C,F,E,C
Close = A,B,D
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Step 5: Node C is removed from open. Its
children G and F is added to the front of open.
Step 6: Node G is expanded and found to
be a goal node. The solution path A-B-D-
C-G is returned and the algorithm
terminates.
Open = G,F,E,C
Close = A,B,D,C
Open = F,E,C
Close = A,B,D,C,G
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Algorithm (DFS)
Input: Two states in the state space, START and GOAL
LOCAL Variables: OPEN, CLOSED State-X, SUCCESSORS
Output: Yes or No
• Method
Form a stack consisting of START and call it OPEN list.
Initially set CLOSED list as empty; Found = false;
While (OPEN ≠empty and Found = false)
DO
{
Remove the first state from OPEN and call it State-X;
Put State-X in the front of CLOSED list;
If State-X= GOAL,
then Found = true
Dr. Amit Kumar, Dept of CSE, JUET, Guna
else
{
-perform EXPAND operation on STATE-X, producing a list of
SUCCESSORS;
-Remove from successors those states, if any, that are in the
CLOSED list;
-Insert SUCCESSORS in the front of the OPEN list /* Stack */
}
}/* end while */
If Found = true
then return yes
else
return No
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Depth First Search
Advantages of Depth First Search
– It require less memory as it only stores a single
path from the root to leaf node along with the
remaining unexpanded siblings for each node on
the path.
• Disadvantages of depth First Search
– It may trapped in a blind alley because it may
follow a single, unfruitful path for a very long time
before the path terminates in a state that has no
successors.
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Issues with BFS and DFS
BFS goes level by level, but requires more space. The space required by DFS is O(d)
where d is depth of tree, but space required by BFS is O(n) where n is number of
nodes in tree.
DFS : The problem with this approach is, if there is a node close to root, but not in first
few subtrees explored by DFS, then DFS reaches that node very late. Also, DFS may not
find shortest path to a node (in terms of number of edges).
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Depth First Iterative Deepening (DFID)
• It suffers neither the drawbacks of BFS nor of DFS on trees
• It takes advantages of both the strategies.
• Since DFID expands all nodes at a given depth before
expanding any nodes at greater depth, it is guaranteed to find a
shortest -length (path) solution from initial state to goal state.
• At any given time, it is performing a DFS and never searches
deeper than depth ‘d’. Hence, it uses same space as DFS.
• Disadvantage of DFID is that it performs wasted computation
prior to reaching the goal depth.Dr. Amit Kumar, Dept of CSE, JUET, Guna
Algorithm (DFID)
Initialize d = 1 /* depth of search tree */ , Found = false
While (Found = false)
DO {
perform a depth first search from start to depth d.
if goal state is obtained
then Found = true
else
discarding the nodes generated in the search of depth d
d = d + 1
}/* end while */
Report the solution
Stop
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Iterative deepening search L=0
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Iterative deepening search L=1
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Iterative deepening search L=2
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Iterative Deepening Search L=3
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Comparison of algorithm
• completeness: does it always find a solution if
one exists?
• time complexity: number of nodes generated
• space complexity: maximum number of nodes in
memory
• optimality: does it always find a least-cost
solution?
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Depth of the tree
Dr. Amit Kumar, Dept of CSE, JUET, Guna
Comparison of BFS, DFS and DFID
Here, B represent the branching factor and d represent the depth of the tree
Dr. Amit Kumar, Dept of CSE, JUET, Guna

More Related Content

What's hot

Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
sandeep54552
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
NivethaS35
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithms
Minakshi Atre
 
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
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
vikas dhakane
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
Jismy .K.Jose
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
Megha Sharma
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
vikas dhakane
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
Dheerendra k
 
Hill climbing
Hill climbingHill climbing
Hill climbing
Mohammad Faizan
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
Amar Jukuntla
 
Problem solving in Artificial Intelligence.pptx
Problem solving in Artificial Intelligence.pptxProblem solving in Artificial Intelligence.pptx
Problem solving in Artificial Intelligence.pptx
kitsenthilkumarcse
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
vikas dhakane
 
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
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
Kapil Dahal
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
Hanif Ullah (Gold Medalist)
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdfUNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
JenishaR1
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
Dr. C.V. Suresh Babu
 

What's hot (20)

Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithms
 
Ai 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
 
Problem solving in Artificial Intelligence.pptx
Problem solving in Artificial Intelligence.pptxProblem solving in Artificial Intelligence.pptx
Problem solving in Artificial Intelligence.pptx
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdfUNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
 

Similar to Uninformed search

AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docx
CS50Bootcamp
 
Searching methodologies
Searching methodologiesSearching methodologies
Searching methodologies
jyoti_lakhani
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
Amey Kerkar
 
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
 
Informed search
Informed searchInformed search
Informed search
Amit Kumar Rathi
 
Best First Search.pptx
Best First Search.pptxBest First Search.pptx
Best First Search.pptx
MuktarulHoque1
 
Artificial intelligence topic for the btech studentCT II.pptx
Artificial intelligence topic for the btech studentCT II.pptxArtificial intelligence topic for the btech studentCT II.pptx
Artificial intelligence topic for the btech studentCT II.pptx
bharatipatel22
 
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
 
Production systems
Production systemsProduction systems
Production systems
Adri Jovin
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
Hema Kashyap
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
Ratnakar Mikkili
 
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 Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
Sagacious IT Solution
 
AI 3 | Uninformed Search
AI 3 | Uninformed SearchAI 3 | Uninformed Search
AI 3 | Uninformed Search
Mohammad Imam Hossain
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
Prof.Dharmishtha R. Chaudhari
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
Yousef Aburawi
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptx
Kirti Verma
 
AI Lesson 04
AI Lesson 04AI Lesson 04
AI Lesson 04
Assistant Professor
 
informed search.pptx
informed search.pptxinformed search.pptx
informed search.pptx
SoundariyaSathish
 
unit-1-l3.ppt
unit-1-l3.pptunit-1-l3.ppt
unit-1-l3.ppt
ssuserec53e73
 

Similar to Uninformed search (20)

AI unit-2 lecture notes.docx
AI unit-2 lecture notes.docxAI unit-2 lecture notes.docx
AI unit-2 lecture notes.docx
 
Searching methodologies
Searching methodologiesSearching methodologies
Searching methodologies
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
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
 
Informed search
Informed searchInformed search
Informed search
 
Best First Search.pptx
Best First Search.pptxBest First Search.pptx
Best First Search.pptx
 
Artificial intelligence topic for the btech studentCT II.pptx
Artificial intelligence topic for the btech studentCT II.pptxArtificial intelligence topic for the btech studentCT II.pptx
Artificial intelligence topic for the btech studentCT II.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
 
Production systems
Production systemsProduction systems
Production systems
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
AI 3 | Uninformed Search
AI 3 | Uninformed SearchAI 3 | Uninformed Search
AI 3 | Uninformed Search
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptx
 
AI Lesson 04
AI Lesson 04AI Lesson 04
AI Lesson 04
 
informed search.pptx
informed search.pptxinformed search.pptx
informed search.pptx
 
unit-1-l3.ppt
unit-1-l3.pptunit-1-l3.ppt
unit-1-l3.ppt
 

More from Amit Kumar Rathi

Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
Hybrid Systems using Fuzzy, NN and GA (Soft Computing)Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
Amit Kumar Rathi
 
Fundamentals of Genetic Algorithms (Soft Computing)
Fundamentals of Genetic Algorithms (Soft Computing)Fundamentals of Genetic Algorithms (Soft Computing)
Fundamentals of Genetic Algorithms (Soft Computing)
Amit Kumar Rathi
 
Fuzzy Systems by using fuzzy set (Soft Computing)
Fuzzy Systems by using fuzzy set (Soft Computing)Fuzzy Systems by using fuzzy set (Soft Computing)
Fuzzy Systems by using fuzzy set (Soft Computing)
Amit Kumar Rathi
 
Fuzzy Set Theory and Classical Set Theory (Soft Computing)
Fuzzy Set Theory and Classical Set Theory (Soft Computing)Fuzzy Set Theory and Classical Set Theory (Soft Computing)
Fuzzy Set Theory and Classical Set Theory (Soft Computing)
Amit Kumar Rathi
 
Associative Memory using NN (Soft Computing)
Associative Memory using NN (Soft Computing)Associative Memory using NN (Soft Computing)
Associative Memory using NN (Soft Computing)
Amit Kumar Rathi
 
Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)
Amit Kumar Rathi
 
Fundamentals of Neural Network (Soft Computing)
Fundamentals of Neural Network (Soft Computing)Fundamentals of Neural Network (Soft Computing)
Fundamentals of Neural Network (Soft Computing)
Amit Kumar Rathi
 
Introduction to Soft Computing (intro to the building blocks of SC)
Introduction to Soft Computing (intro to the building blocks of SC)Introduction to Soft Computing (intro to the building blocks of SC)
Introduction to Soft Computing (intro to the building blocks of SC)
Amit Kumar Rathi
 
Topological sorting
Topological sortingTopological sorting
Topological sorting
Amit Kumar Rathi
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
Amit Kumar Rathi
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
Amit Kumar Rathi
 
Sccd and topological sorting
Sccd and topological sortingSccd and topological sorting
Sccd and topological sorting
Amit Kumar Rathi
 
Red black trees
Red black treesRed black trees
Red black trees
Amit Kumar Rathi
 
Recurrence and master theorem
Recurrence and master theoremRecurrence and master theorem
Recurrence and master theorem
Amit Kumar Rathi
 
Rabin karp string matcher
Rabin karp string matcherRabin karp string matcher
Rabin karp string matcher
Amit Kumar Rathi
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Amit Kumar Rathi
 
Merge sort analysis
Merge sort analysisMerge sort analysis
Merge sort analysis
Amit Kumar Rathi
 
Loop invarient
Loop invarientLoop invarient
Loop invarient
Amit Kumar Rathi
 
Linear sort
Linear sortLinear sort
Linear sort
Amit Kumar Rathi
 
Heap and heapsort
Heap and heapsortHeap and heapsort
Heap and heapsort
Amit Kumar Rathi
 

More from Amit Kumar Rathi (20)

Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
Hybrid Systems using Fuzzy, NN and GA (Soft Computing)Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
Hybrid Systems using Fuzzy, NN and GA (Soft Computing)
 
Fundamentals of Genetic Algorithms (Soft Computing)
Fundamentals of Genetic Algorithms (Soft Computing)Fundamentals of Genetic Algorithms (Soft Computing)
Fundamentals of Genetic Algorithms (Soft Computing)
 
Fuzzy Systems by using fuzzy set (Soft Computing)
Fuzzy Systems by using fuzzy set (Soft Computing)Fuzzy Systems by using fuzzy set (Soft Computing)
Fuzzy Systems by using fuzzy set (Soft Computing)
 
Fuzzy Set Theory and Classical Set Theory (Soft Computing)
Fuzzy Set Theory and Classical Set Theory (Soft Computing)Fuzzy Set Theory and Classical Set Theory (Soft Computing)
Fuzzy Set Theory and Classical Set Theory (Soft Computing)
 
Associative Memory using NN (Soft Computing)
Associative Memory using NN (Soft Computing)Associative Memory using NN (Soft Computing)
Associative Memory using NN (Soft Computing)
 
Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)
 
Fundamentals of Neural Network (Soft Computing)
Fundamentals of Neural Network (Soft Computing)Fundamentals of Neural Network (Soft Computing)
Fundamentals of Neural Network (Soft Computing)
 
Introduction to Soft Computing (intro to the building blocks of SC)
Introduction to Soft Computing (intro to the building blocks of SC)Introduction to Soft Computing (intro to the building blocks of SC)
Introduction to Soft Computing (intro to the building blocks of SC)
 
Topological sorting
Topological sortingTopological sorting
Topological sorting
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Sccd and topological sorting
Sccd and topological sortingSccd and topological sorting
Sccd and topological sorting
 
Red black trees
Red black treesRed black trees
Red black trees
 
Recurrence and master theorem
Recurrence and master theoremRecurrence and master theorem
Recurrence and master theorem
 
Rabin karp string matcher
Rabin karp string matcherRabin karp string matcher
Rabin karp string matcher
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Merge sort analysis
Merge sort analysisMerge sort analysis
Merge sort analysis
 
Loop invarient
Loop invarientLoop invarient
Loop invarient
 
Linear sort
Linear sortLinear sort
Linear sort
 
Heap and heapsort
Heap and heapsortHeap and heapsort
Heap and heapsort
 

Recently uploaded

Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
vmspraneeth
 
Properties of Fluids, Fluid Statics, Pressure Measurement
Properties of Fluids, Fluid Statics, Pressure MeasurementProperties of Fluids, Fluid Statics, Pressure Measurement
Properties of Fluids, Fluid Statics, Pressure Measurement
Indrajeet sahu
 
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
Sou Tibon
 
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEERDELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
EMERSON EDUARDO RODRIGUES
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
MuhammadJazib15
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
b0754201
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
DharmaBanothu
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
Kamal Acharya
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
Pallavi Sharma
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
Kamal Acharya
 
Introduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.pptIntroduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.ppt
Dwarkadas J Sanghvi College of Engineering
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
Kamal Acharya
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
Introduction to Artificial Intelligence.
Introduction to Artificial Intelligence.Introduction to Artificial Intelligence.
Introduction to Artificial Intelligence.
supriyaDicholkar1
 

Recently uploaded (20)

Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
 
Properties of Fluids, Fluid Statics, Pressure Measurement
Properties of Fluids, Fluid Statics, Pressure MeasurementProperties of Fluids, Fluid Statics, Pressure Measurement
Properties of Fluids, Fluid Statics, Pressure Measurement
 
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
309475979-Creativity-Innovation-notes-IV-Sem-2016-pdf.pdf
 
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEERDELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
DELTA V MES EMERSON EDUARDO RODRIGUES ENGINEER
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
 
Introduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.pptIntroduction to Computer Networks & OSI MODEL.ppt
Introduction to Computer Networks & OSI MODEL.ppt
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
 
Introduction to Artificial Intelligence.
Introduction to Artificial Intelligence.Introduction to Artificial Intelligence.
Introduction to Artificial Intelligence.
 

Uninformed search

  • 1. Uninformed Search Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 2. Problem Solving • Two ways to solve the problem are – Search based approaches – Knowledge based approaches Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 3. Search based approaches Used some representation of problem domain, than simulate what would happen in domain as a consequence of action and try to find the solution Simple trial -and -error approach can be applied to solve the problem In these approaches, prior knowledge of the problem domain is not required Can be easily applied to any real world problem Use some knowledge to represent the domain, however, the solution may or may not use domain knowledge – Uninformed search » Actions are well defined, does not use any domain knowledge to choose most likely candidate – Informed search » Attempt to choose most likely candidate based on domain knowledge Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 4. Knowledge based approach • Can be of two types – Memory or case based approach • These approaches used some solved problem and then apply their solution to solve new unknown problem. • Use a database of that contains pair of problem and solution • Ex: integration solving – Rule based approach • Use many solved problems and domain expert to infer the knowledge • Store knowledge in form of rules • Apply rules to solve new problem • Ex: Expert System Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 5. Problem Solving Using Uniformed search Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 6. Uninformed search • These strategies use only the information available in the problem definition. – Generate and Test – Breadth-first search – Depth-first search – Depth-limited Iterative deepening search Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 7. State space • Formulate a problem as a state space by showing the legal problem states, the legal operators/action, and the initial and goal states . • A state is defined by the specification of the values of all attributes of interest in the world • An operator changes one state into the other; it has a precondition which is the value of certain attributes prior to the application of the operator, and a set of effects, which are the attributes altered by the operator • The initial state is where you start • The goal state is the partial description of the solution Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 8. Generate and Test •The algorithm always picks the first node from state space for test. •If the node contains a goal state, the success is returned. • Otherwise, the successor of the node is generated and same process is repeated Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 9. Generate and Test: Simple Search-1 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 10. Cycle formation in Simple Search-1 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 11. Generate and Test: Simple Search-2 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 12. Cycle formation in Simple Search-2 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 13. Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 14. Generate and Test: with path information Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 15. Few more refinements • Always pick the first node in the list • There are two choices regarding addition of successor nodes to the open – Add successor nodes to the head of open list – Add successor nodes to the tail of open list Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 16. Breadth First Search (BFS) • It expands all the states one step away from the initial state, then expands all states two steps from initial state, then three steps etc., until a goal state is reached. • It expands all nodes at a given depth before expanding any nodes at a greater depth. • All nodes at the same level are searched before going to the next level down. • We can implement it by using two lists called OPEN and CLOSED. The OPEN list contains those states that are to be expanded and CLOSED list keeps track of states already expanded. Here OPEN list is used as a queue. • BFS is effective when the search tree has a low branching factor. Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 17. BFS illustration State Space Graph State-Space tree Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 18. BFS illustration Step 1: Initially open contains only one node corresponding to the source state A. Step 2: A is removed from open. The node is expanded, and its children B and C are generated. They are placed at the back of open. Open = A Close = {} Open = BC Close = {A} Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 19. Step 3: Node B is removed from open and is expanded. Its children D, E are generated and put at the back of open. Step 4: Node C is removed from open and is expanded. Its children D and G are added to the back of open. Open = C,D,E Close = AB Open = D,E,D,G Close = A,B,C Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 20. Step 5: Node D is removed from open. Its children C and F are generated and added to the back of open. Step 6: Node E is removed from open. It has no children Open = E, D,G,C,F Close = A,B,C,D Open = D,G,C,F Close = A,B,C,D,E Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 21. Step 7: D is expanded, B and F are put in OPEN. Step 8: G is selected for expansion. It is found to be a goal node. So the algorithm returns the path A C G by following the parent pointers of the node corresponding to G. The algorithm terminates. Open = C,F,B,F Close = A,B,C,D,E,G Open = G,C,F,B,F Close = A,B,C,D,E,D Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 22. Algorithm (BFS) Input: Two states in the state space START and GOAL Local Variables: OPEN, CLOSED, STATE-X, SUCCS Output: Yes or No Method: Initially OPEN list contains a START node and CLOSED list is empty; Found = false; While (OPEN ≠empty and Found = false) Do { Remove the first state from OPEN and call it STATE-X; Put STATE-X in the front of CLOSED list; If STATE-X = GOAL then Found = true Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 23. else { -perform EXPAND operation on STATE-X, producing a list of SUCCESSORS; -Remove from successors those states, if any, that are in the CLOSED list; -Append SUCCESSORS at the end of the OPEN list/*queue*/ } } /* end while */ If Found = true then return Yes else return No and Stop Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 24. Breadth First Search • Advantages of Breadth First Search – Finds the path of minimal length to the goal. – BFS can work even in trees that are infinitely deep. • Disadvantages of Breadth First Search – Requires the generation and storage of a tree whose size is exponential Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 25. Depth-First Search • In depth-first search we go as far down as possible into the search tree / graph before backing up and trying alternatives. • It works by always generating a descendent of the most recently expanded node until some depth cut off is reached and then backtracks to next most recently expanded node and generates one of its descendants. • So only path of nodes from the initial node to the current node is stored in order to execute the algorithm. Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 26. • Again use two lists called OPEN and CLOSED with the same conventions explained earlier. • Here OPEN list is used as a stack. • If we discover that first element of OPEN is the Goal state, then search terminates successfully. Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 27. DFS illustration State Space Graph State-Space tree Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 28. DFS illustration Step 1: Initially open contains only one node corresponding to the source state A. Step 2: A is removed from open. The node A is expanded, and its children B and C are generated. They are placed at the front of open. Open = A Close = {} Open = BC Close = {A} Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 29. Step 3: Node B is removed from open and is expanded. Its children D, E are generated and put at the front of open. Step 4: Node D is removed from open and is expanded. Its children C and F are added to the front of open. Open = D,E,C Close = AB Open = C,F,E,C Close = A,B,D Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 30. Step 5: Node C is removed from open. Its children G and F is added to the front of open. Step 6: Node G is expanded and found to be a goal node. The solution path A-B-D- C-G is returned and the algorithm terminates. Open = G,F,E,C Close = A,B,D,C Open = F,E,C Close = A,B,D,C,G Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 31. Algorithm (DFS) Input: Two states in the state space, START and GOAL LOCAL Variables: OPEN, CLOSED State-X, SUCCESSORS Output: Yes or No • Method Form a stack consisting of START and call it OPEN list. Initially set CLOSED list as empty; Found = false; While (OPEN ≠empty and Found = false) DO { Remove the first state from OPEN and call it State-X; Put State-X in the front of CLOSED list; If State-X= GOAL, then Found = true Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 32. else { -perform EXPAND operation on STATE-X, producing a list of SUCCESSORS; -Remove from successors those states, if any, that are in the CLOSED list; -Insert SUCCESSORS in the front of the OPEN list /* Stack */ } }/* end while */ If Found = true then return yes else return No Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 33. Depth First Search Advantages of Depth First Search – It require less memory as it only stores a single path from the root to leaf node along with the remaining unexpanded siblings for each node on the path. • Disadvantages of depth First Search – It may trapped in a blind alley because it may follow a single, unfruitful path for a very long time before the path terminates in a state that has no successors. Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 34. Issues with BFS and DFS BFS goes level by level, but requires more space. The space required by DFS is O(d) where d is depth of tree, but space required by BFS is O(n) where n is number of nodes in tree. DFS : The problem with this approach is, if there is a node close to root, but not in first few subtrees explored by DFS, then DFS reaches that node very late. Also, DFS may not find shortest path to a node (in terms of number of edges). Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 35. Depth First Iterative Deepening (DFID) • It suffers neither the drawbacks of BFS nor of DFS on trees • It takes advantages of both the strategies. • Since DFID expands all nodes at a given depth before expanding any nodes at greater depth, it is guaranteed to find a shortest -length (path) solution from initial state to goal state. • At any given time, it is performing a DFS and never searches deeper than depth ‘d’. Hence, it uses same space as DFS. • Disadvantage of DFID is that it performs wasted computation prior to reaching the goal depth.Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 36. Algorithm (DFID) Initialize d = 1 /* depth of search tree */ , Found = false While (Found = false) DO { perform a depth first search from start to depth d. if goal state is obtained then Found = true else discarding the nodes generated in the search of depth d d = d + 1 }/* end while */ Report the solution Stop Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 37. Iterative deepening search L=0 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 38. Iterative deepening search L=1 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 39. Iterative deepening search L=2 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 40. Iterative Deepening Search L=3 Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 41. Comparison of algorithm • completeness: does it always find a solution if one exists? • time complexity: number of nodes generated • space complexity: maximum number of nodes in memory • optimality: does it always find a least-cost solution? Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 42. Depth of the tree Dr. Amit Kumar, Dept of CSE, JUET, Guna
  • 43. Comparison of BFS, DFS and DFID Here, B represent the branching factor and d represent the depth of the tree Dr. Amit Kumar, Dept of CSE, JUET, Guna