CPSC 322, Fall 2007
Solutions to Midterm Examination
1
Short Answers [6 points each]
1. (What is AI?) Explain why the following statement is true or false: In order to pass the Turing test,
a computer would have to behave at least as rationally as a human. Answer: False: the Turing test
doesn’t appeal to the concept of rationality.
2. (Search) Explain what the frontier is in a graph-search problem, and what it is used for. Answer:
The frontier is a set of paths from the start node to intermediate (non-goal) nodes which are stored by
the search algorithm. The frontier is used for determining the next node that will be explored in the
search.
3. (Search) Is the max of two admissible heuristics also admissible? Why or why not? Answer: Yes, the
max of two admissible heuristics is itself admissible, because each of the two heuristics is guaranteed
to underestimate the distance from the given node to the goal, and so therefore must their max.
4. (Search) Explain the distinction between optimality and optimal efficiency for search algorithms.
Answer: Optimality means that if the algorithm terminates, it finds a minimal-cost goal. Optimal
efficiency means that, among all optimal algorithms, the given algorithm expands the smallest possible
number of nodes.
ONML
HIJK
Z
q
q
q
q
q
q
qqq
qqq
HIJK
ONML
X M
MMM
MM
C2
C1
MMM
MMM
ONML
HIJK
Y
Figure 1: A constraint graph
5. (CSPs) Consider the constraint graph in Figure 1. Imagine that arc consistency has just reduced the
domain of X as a result of considering the edge hX, C1 i. Do we have to add the edge hX, C2 i back
to the list of “to-do arcs”? Why or why not? Answer: No. If this edge was arc consistent before,
removing one of X’s values will only make it easier to show that it is still arc consistent.
6. (CSPs) Consider the following statement: every problem that can be defined as a CSP where variables
have finite domains can also be defined as a search problem using a state-based representation. Explain
why it is true or false; if true, explain what would correspond to a state, and if false, give a counterexample. Answer: True: A state is an assignment of values to zero or more variables. The successors
of a state assign a value to one more variable. From a start-state where no values are assigned, every
complete assignment can be reached. The goal states are any complete assignments that violate none
of the constraints.
7. (Local Search) Define a plateau. Why are plateaus a problem for local search? Answer: A plateau
is a set of neighbouring states in which the scoring function is the same. It is a problem for local search
because hill-climbing is impossible: many or all neighbours score the same, and so if scoring function
is used as a basis for choosing neighbours, the search can cycle.
8. (Local Search) How would you change a local search algorithm to better find global maxima that
are surrounded by local maxima? Assume that the neighbour relation is fixed. Answer: Random
restarts.
9. (Planning) What is a node in the search space of forward planning? Answer: complete assignments
to variables.
10. (Planning) Consider two actions a1 and a2 , where neither the two actions’ precondition or effect lists
have any overlap (i.e., all lists refer to entirely different variables). Compare the worst-case running
time of a CSP planner with and without a mutex constraint between a1 and a2 (you do not have to
provide a formula)? Answer: In the worst case the plan must be unrolled further in the case with a
mutex constraint than without; this would lead to an exponentially greater running time.
2
Search [22 points]
Consider the following directed graph where a is the start node and k and n are both goal nodes, the true
cost function is given by the edge labels, and h is an admissible heuristic function.
?>=<
89:;
GFED
@ABC
a =o
m
?
3
==
==6
2
==
3
==
4
20 / ?>=<
89:;
7654
0123
?>=<
89:;
89:;
/?>=<
c
k
b _?
//
??
//
??
?
//
3 ??
?
//
//12
89:;
?>=<
2
? e
//
//
2
//
?>=<
89:;
89:;
?>=<
7654
0123
n
d
node
a
b
c
d
e
k
m
n
h(node)
16
16
11
20
18
0
2
0
1. [5 points] A∗
Assume that ties are broken alphabetically.
(a) What sequence of paths is expanded by A∗ ? (If you like, you can describe each path just by giving
the last node in the path.)
(b) What path is returned?
(c) What is the cost of this path?
Answer: A∗ expands acmn and returns the path acn which costs 18.
2. [5 points] Branch-and-bound search
Assume that ties are broken alphabetically.
(a) What sequence of paths is expanded by branch-and-bound? (If you like, you can describe each
path just by giving the last node in the path.)
(b) What path is returned?
(c) What is the cost of this path?
Answer: Branch-and-bound expands abckmncn and returns the path acn which costs 18.
3. [5 points] Iterative-Deepening A∗ (IDA∗ )
Suppose we use the following sequence of depth bounds: 17.5,20.5,23.5,26.5,. . . Assume that ties are
broken alphabetically.
(a) What sequence of paths is expanded by IDA∗ ? (If you like, you can describe each path just by
giving the last node in the path.)
(b) What path is returned?
(c) What is the cost of this path?
Answer: For f (n)-bound 17.5, IDA∗ expands acm but doesn’t find a goal. For f (n)-bound 20.5, IDA∗
expands abcmncmn and returns the path acn which costs 18.
4. [7 points] Consider a complete binary search tree with finite depth d, and with only one goal, which
is at depth k < d. The search begins at the root node (let’s call this node’s depth 1).
(a) In the best case:
i. Exactly how many nodes would be expanded by breadth-first search?
Answer: 2k−1 nodes.
ii. Exactly how many paths would be on the frontier just before the goal node is expanded?
Answer: 2k−1 paths.
(b) In the best case:
i. Exactly how many nodes would be expanded by depth-first search?
Answer: k nodes.
ii. Exactly how many paths would be on the frontier just before the goal node is expanded?
Answer: k paths.
3
[18 points] CSP Planning
Consider the one-stage unrolling of a CSP planning problem represented below:
GotoB 0
{T,F}
Goto1 0
{T,F}
Elevator 0
{B,1,2,3,4}
C4
Elevator 1
{B,1,2,3,4}
C5
Passenger 1
{B,1,2,3,4,E}
Goto2 0
{T,F}
Goto3 0
{T,F}
C1
Goto4 0
{T,F}
C2
PickUp 0
{T,F}
C3
DropOff 0
{T,F}
Passenger 0
{B,1,2,3,4,E}
C6
where the constraint tables1 are as follows (with ∗ representing a wildcard or don’t-care condition).
C1
Elevator 0
B
Passenger 0
1
C2
Elevator 0
1
∗
Passenger 0
1
∗
1 Recall
PickUp 0
T
F
that constraint tables list the joint variable assignments that are allowed.
C3
Passenger 0
E
∗
C4
Elevator 0
B
1
2
3
4
∗
∗
∗
∗
∗
C5
Passenger 0
B
1
2
3
4
E
1
E
C6
Passenger 1
4
Elevator
4
∗
GotoB 0
F
F
F
F
F
T
F
F
F
F
PickUp 0
F
F
F
F
F
F
T
F
DropOff 0
T
F
Goto1 0
F
F
F
F
F
F
T
F
F
F
Goto2 0
F
F
F
F
F
F
F
T
F
F
DropOff 0
F
F
F
F
F
F
F
T
Goto3 0
F
F
F
F
F
F
F
F
T
F
Goto4 0
F
F
F
F
F
F
F
F
F
T
Elevator 1
B
1
2
3
4
B
1
2
3
4
Passenger 1
B
1
2
3
4
E
E
4
1. [5 points] Perform arc-consistency on this CSP. (Just cross out the values on the figure above).
Answer: Arc consistency will eliminate every value from every domain. By C6, dom(Passenger 1) = {4}.
By C1, dom(Passenger 0) = {1}. Because of this, there is no satisficing assignment for C5, meaning we can
eliminate every value from Passenger 0, Passenger 1, PickUp 0 and DropOff 0. Any constraint connected
to a variable with an empty domain cannot be satisfied, which means we can eliminate the domain of every
connected variable.
2. [8 points] Give a STRIPS representation of the problem, including variables, domains, start state, goal states
and action descriptions.
Answer: Variables: Elevator, Passenger
dom(Elevator) = {B,1,2,3,4}
dom(Passenger) = {B,1,2,3,4,E}
Start State: Elevator=B,Passenger=1
Goal State: Elevator=∗,Passenger=4
Action
GotoB
Goto1
Goto2
Goto3
Goto4
PickUp
DropOff
Precondition
Elevator=1,Passenger=1
Elevator=4,Passenger=E
Effect
Elevator=B
Elevator=1
Elevator=2
Elevator=3
Elevator=4
Passenger=E
Passenger=4
3. [5 points] What is the smallest horizon for which this CSP planner can be solved? Justify your answer and
report the plan that it would find.
Answer: 3 is the smallest horizon for which this set of CSPs has a solution. The plan it would find is
<<Goto1>,<PickUp,Goto4>,<DropOff>> or <<Goto1>,<PickUp,Goto4>,<DropOff,Goto∗ >>. Because
any plan that solves the problem must have actions PickUp and DropOff in it and they are mutually exclusive
(because they have conflicting preconditions and effects), the horizon must be at least 2. Because neither of
those actions is possible at the first step (because preconditions are not met), the horizon must be at least 3.
© Copyright 2026 Paperzz