You are on page 1of 4

Subject : AI

Dr. Yasser Fouad


Search Sheet

1. The following diagram shows a partially expanded search tree. Each arc is labeled
with a corresponding step cost, and the leaves are labeled with the h (heuristic)
value.

Answer these three questions:


1. Which leaf will be expanded next by a greedy best-first search?
2. Which leaf will be expanded next by a uniform-cost search?
3. Which leaf will be expanded next by an A* search?

2. Create a subclass of Problem to represent the “Fifteen-Grid Problem,” create


some instances of the problem, and run the code using the Instrumented Problem
class to compare various search algorithms. The tiles may start out in any
position, and the point of the game is to get the tiles to be arranged like the picture
below while using the fewest number of “tile-slides”:

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15
3. Suggest a heuristic of your own to solve the 8-puzzle problem using A* algorithm
and starting from the initial state
1 3 5 to the goal state 1 2 3
4 2 - 4 5 6

1
7 8 6 7 8 -

4. The figure shows a world consisting of a table and 3 blocks. A legal operation is
to move block X onto block Y provided both X and Y have nothing ob their top,
or to move block X onto the table. Draw the search tree generated by a Breadth
first search strategy to reach a goal state.

1
1 2
2 3 3

Initial Goal state


state
5. Consider the search space below, where S is the start node and G1, G2, and G3
satisfy the goal test. Arcs are labelled with the cost of traversing them and the
estimated cost to a goal is reported inside nodes. For each of the following search
strategies, indicate which goal state is reached (if any).
a) Hill Climbing
b) A*

S
3 8 5
81 C
2 3
A B
9 6 1
4 11
7
10
2 G
D
4 3
2 E 0
1
5 1
G 0
1
0

F
G 5
2
0
6. Consider the following problem.
A

1 1
0
5 B 5
S G

1 5 2
5
C
Show how Uniform cost search and Depth first would find the optimal route from
S to G
7. Consider a search space implicitly specified by a set of rules given
below. A rule p q1, q2, . . . , qn means problem p is solved if each
sub-problem qi is solved. Assume that A is the start node; the cost of a
k-connector is k; for a state representing a primitive problem, the h
value is 0; and any problem or sub problem that has a non-zero h
value and cannot be decomposed into sub problems is unsolvable.
Rules specifying the search space:
•AB •AC •BD • B E • C F,G
• D H, I • E J,K,L • F M • G N • G O
• G P • H Q • H R • I R • L J, S,M
•NU • O  T,U •PU
The value v returned by heuristic function for a node x is specified by entries of the form
x(v) in the following list: A(1), B(3), C(2), D(3), E(4), F(1), G(10), H(2), I(3), J(0), K(0),
L(2), M(0), N(16), O(5), P(27), Q(50), R(30), S(0), T(90), U(200). Draw the search
space generated by A* by showing successive snapshots of the search tree after each of
the first four node expansions. (Expanding a node means applying all applicable rules
at the node and generating the node’s successors. For example, expanding A yields
two successors B and C and A can be solved by solving either B or C.) In each
snapshot, include the current estimated cost of the minimum cost solution rooted at
each node.

8. Consider the following search problem. Assume a state is represented as an


integer, that the initial state is the number 1, and that the two successors of a
state n are the states 2n and 2n+1. For example, the successors of 1 are 2 and 3,
the successors of 2 are 4 and 5, the successors of 3 are 6 and 7, etc. Assumes
the goal state is the number 12. Consider the following heuristics for evaluating
the state n where the goal state is g
h1(n) = |n-g| & h2(n) = (g – n) if (n  g) and h2 (n) =  if (n >g)
Show the search trees generated for each of the following strategies for the initial state 1
and the goal state 12, numbering the nodes in the order expanded.
a) Depth-first search b) Breadth-first search
c) beast-first with heuristic h1 d) A* with heuristic (h1+h2)
If any of these strategies get lost and never find the goal, then show the few steps and
say "FAILS"

3
9. The start node is M, goal node is R, Search for goal by
a) Depth first method c) Breadth first method
b) A* d) Greedy method

You might also like