0% found this document useful (0 votes)
12 views

Class-4_Search Algorithems

Uploaded by

22r11a05t5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Class-4_Search Algorithems

Uploaded by

22r11a05t5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Search Algorithms

Search algorithms :
• Based on the search problems we can classify the search
algorithms into
1. uninformed search (Blind search)
2. informed search (Heuristic search)

Uninformed/Blind Search:
• The uninformed search does not contain any domain
knowledge such as closeness, the location of the goal.
• It operates in a brute-force way as it only includes
information about how to traverse the tree and how to
identify leaf and goal nodes.

• Uninformed search applies a way in which search tree is


searched without any information about the search space
like initial state operators and test for the goal, so it is
also called blind search.

• It examines each node of the tree until it achieves the goal


node.
It can be divided into five main types:

• Breadth-first search
• Uniform cost search
• Depth-first search
• Iterative deepening depth-first search
• Bidirectional Search
Informed Search :
• Informed search algorithms use domain knowledge. In an

informed search, problem information is available which

can guide the search.

• Informed search strategies can find a solution more

efficiently than an uninformed search strategy.

• Informed search is also called a Heuristic search.


• A heuristic is a way which might not always be

guaranteed for best solutions but guaranteed to find a

good solution in reasonable time.

• Informed search can solve much complex problem which

could not be solved in another way.

Example :
• Greedy Search

• A* Search
Breadth-first search :
• Explore nodes in tree order: library, school, hospital,
factory, park, newsagent, uni, church.
• (conventionally explore left to right at each level)
Depth first search : Nodes explored in order: library,
school, factory, hospital, park, newsagent, universities
• Water Jug Problem: you have two jugs with

capacity of 4-gallons and 3-gallons.There is a

pump can be used to fill jugs with water. How

can you get exactly 2- gallons of water in to 4-

gallons capacity jug….i.e….(2,0)


Approaches :
• 1. Blind Search
• Breath first search
• Depth first search
• 2.Heuristic Search
• Production Rules (or) Conditions

Operations :

1. Empty Operation
2. Fill Operation
3. Transfer Operation
• Breath first search :
• Depth first Search Algorithm :
• Depth first Search Algorithm :
Heuristic Search :
• Production rules for solving the water jug problem :
The listed production rules contain all the actions that
could be performed by the agent in transferring the
contents of jugs. But, to solve the water jug problem in a
minimum number of moves, following set of rules in the
given sequence should be performed:

• Here, let x denote the 4-gallon jug and y denote the 3-


gallon jug.
Description of action
S.NO Initial State Condition Final state
taken
Fill the 4 gallon jug
1 (x,y) If x<4 (4,y)
completely
Fill the 3 gallon jug
2 (x,y) if y<3 (x,3)
completely
Pour some part from the 4
3 (x,y) If x>0 (x-d,y)
gallon jug
Pour some part from the 3
4 (x,y) If y>0 (x,y-d)
gallon jug
5 Empty the 4 gallon jug (x,y) If x>0 (0,y)
6 Empty the 3 gallon jug (x,y) If y>0 (x,0)
Pour some water from the 3
7 gallon jug to fill the four (x,y) If (x+y)<7 (4, y-[4-x])
gallon jug
Pour some water from the 4
8 gallon jug to fill the 3 gallon (x,y) If (x+y)<7 (x-[3-y],y)
jug.
Pour all water from 3 gallon
9 (x,y) If (x+y)<4 (x+y,0)
jug to the 4 gallon jug
Pour all water from the 4
10 (x,y) if (x+y)<3 (0, x+y)
gallon jug to the 3 gallon jug
• Initially both jugs are empty
• Fill the 3 gallon jug completely
• Pour all water from 3 gallon jug to the 4 gallon jug
• Fill the 3 gallon jug completely
• Pour some water from the 3 gallon jug to fill the four
gallon jug
• Empty the 4 gallon jug
• Pour all water from 3 gallon jug to the 4 gallon jug
4 gallon jug 3 gallon jug Rule
S.NO contents contents followed

1 0 gallon 0 gallon Initial state

2 0 gallon 3 gallons Rule no.2

3 3 gallons 0 gallon Rule no. 9

4 3 gallons 3 gallons Rule no. 2

5 4 gallons 2 gallons Rule no. 7

6 0 gallon 2 gallons Rule no. 5

7 2 gallons 0 gallon Rule no. 9


Example: Solve the given problem using Breadth-first
search approach and depth first search approach. Here

You might also like