2_Problem_searching_methods
2_Problem_searching_methods
Search methods
A
C B
A B C
Start: ON(C, A) ….
Goal: ON(B, C) ON(A, B)
◼ Problem statement:
❑ Given two jugs, a 4-gallon and 3-gallon having no
measuring markers on them. There is a pump that can be
used to fill the jugs with water. How can you get exactly 2
gallons of water into 4-gallon jug.
◼ Solution:
❑ State for this problem can be described as the set of
ordered pairs of integers (X, Y) such that
◼ X represents the number of gallons of water in 4-gallon jug
and
◼ Y for 3-gallon jug.
❑ Start state is (0,0)
❑ Goal state is (2, N) for any value of N.
(0, 0)
(4, 0) (0, 3)
(4, 0) (0, 3)
(4, 0)
(0, 3) (4, 0)
◼ Consider 5 cities.
❑ A salesman is supposed to visit each of 5 cities.
❑ All cities are pair wise connected by roads.
❑ There is one start city.
❑ The problem is to find the shortest route for the
salesman who has to
◼ visit each city only once and
◼ returns to back to start city.
C1
7 12 15 11
20
C2 10 13 C3
12 C4 17
5
C5
D(C1,C2) = 7; D(C1,C3) = 11; D(C1,C4) = 12; D(C1,C5) = 15; D(C2,C3) =20;
D(C2,C4) = 10; D(C2,C5) =12; D(C3,C4) =13; D(C3,C5) = 17; D(C4,C5) =5;