## Sample Exam Problems

### Problem 1:

Consider the following simple PCFG:
```S -> Noun VP  [0.5]
S -> NP Verb  [0.5]
VP -> Verb Noun [1.0]
Noun -> "bronze" [0.1]
Noun -> "pots" [0.6]
Noun -> "clatter" [0.3]
Verb -> "bronze" [0.1]
Verb -> "pots" [0.1]
Verb -> "clatter" [0.8]
```

A. Show the two possible parse trees for the sentence "bronze pots clatter" and label each node with its probability. You may write the probability as a product e.g. "0.2*0.3*0.4"; this is not an test on how well you can multiply. Hint: it is more efficient to think about this problem top-down than to try to simulate the CYK parser, which works bottom-up.

B. The CYK parser will add some nodes to the chart that are not in either of the parse trees. Give an example of one such node.

Answer: The two starred nodes below

### Problem 2:

What is the result of doing alpha-beta pruning in the game tree shown below? (Draw your answer on the exam sheet.)

### Problem 3:

Consider the following collection of sentences in the propositional logic.
1. P => (Q <=> R).
2. Q <=> ~(R^W)
3. Q => (P^W).
A. Convert this set to CNF. (You need not show the intermediate steps.)

1A. ~P V ~Q V R
1B. ~P V Q V ~R
2A. ~Q V ~R V ~W
2B. Q V R
2C. Q V W
3A P V ~Q
3B ~Q V W

B. Show how the Davis-Putnam assignment finds a satisfying assumption. (Assume that, when a branch point is reached, the algorithm chooses the first atom alphabetically and tries TRUE before FALSE.)

```Set S0 as above.

Try P=TRUE.  Delete clause 3, delete ~P from 1A,  1B.

Set S1
1A. ~Q V R
1B. Q V ~R
2A. ~Q V ~R V ~W
2B. Q V R
2C. Q V W
3B  ~Q V W

Try Q=TRUE. Delete clauses 1B, 2B, 2C, delete ~Q from 1A, 2A, 3B.

1A.  R
2A. ~R V ~W
3B   W

1A is a singleton clause. Set R=TRUE. Delete 1A,  delete ~R from 2A.

2A. ~W
3B. W

2A is a singleton clause.  Set W=FALSE.  Delete 2A, delete W from 3B.

3B is the null clause. Fail.

Return to S1. Try Q=FALSE. Delete 1A, 2A, 3B, delete Q from 1B, 2B, 2C,

1B. ~R
2B.  R
2C.  W

1B is a singleton clause. Set R=FALSE. Delete 1B, delete R from 2B.

2B is the null clause. Fail

Return to S0.  Try P=FALSE. Delete 1A, 1B.  Delete P from 3A.

2A.  ~Q V ~R V ~W
2B.  Q V R
2C.  Q V W
3A    ~Q
3B   ~Q V W

3A is a singleton clause. Set Q=FALSE.
Delete 2A, 3B, delete Q from 2B, 2C.

2B. R
2C. W

2B and 2C are singleton clauses. Set R=TRUE, W=TRUE. Succeed

P=FALSE, Q=FALSE, R=TRUE, W=TRUE.
```

### Problem 4:

Let G be an undirected graph. An independent set in G is a set of vertices Z such that no two vertices I,J in Z are connected by an edge. For instance, in the graph shown below, the set { E,F,H } is an independent set because the graph does not contain any of the edges EF, EH, or FH.

The INDEPENDENT SET problem is, given a graph G and an integer K, find an independent set in G of size K.

Consider the problem of finding the largest independent set in a graph G. Suppose that you want to use a blind search method (DFS, BFS, or iterative deepening) to solve the problem.

• Describe a state space for this problem. You should specify (a) what are the states; (b) what are the operators, or what are the successor states; (c) what is the start state; (d) what is the goal.

Answer: The problem was inconsistently worded; it first defines the goal as finding an independent set of size K, then redefines it to be the problem of finding the largest independent set. I'll answer the first wording.

State: A list of at most K vertices in alphabetical order such that no two vertices are connected by an edge.

Operator: Given a state S, add some vertex alphabetically later than the vertices in S that is not connected by edges to any of the vertices in S.

Start state: The empty list.

Goal state: A state with K vertices.

• If the graph G has N vertices, what is the depth and the branching factor of your state space? Is it a tree? Is the depth of the shallowest goal known?

Answer: Depth: K. Branching factor: N (at the root). The space is a tree. The goal is at depth K.

• Which would be the best algorithm for this problem: depth-first search, breadth-first search, or iterative deepening?

### Problem 5:

Continuing with the INDEPENDENT SET problem from problem 5, Suppose that you now want to solve the problem "Does there exist an independent set of size K?" for some specific K. You want to solve the problem by translating it into satisfiability.

An instance of the INDEPENDENT SET problem can be translated into propositional satisfiability as follows: For each vertex V and for each integer I=1 .. K, define the atom V_I to be the assertion that V is the Ith vertex, alphabetically, in the set Z. Define the atom V_in to be the assertion that V is in the set Z. One then needs the following four types of constraints:

1. V is in Z if and only if V is the Ith vertex in Z for some value of I.
2. For I > 1, if V is the Ith vertex in Z then one of the vertices alphabetically before V is the (I-1)st vertex in Z. (If V is the first vertex alphabetically in G, then this amounts to the statement that V is not the second or third or fourth ... or Kth vertex in Z.)
3. If U and V are connected in G then U and V are not both in Z.
4. Some vertex is the Kth vertex in Z.
Give one instance of each of these four types of constraints that would be generated for the graph shown in problem 5 with K=3.