Sample Mid-Term Exam

Problem 1

The PARTITION problem is defined as follows: The input is a list L of numbers. The output is either (A) a partition of L into two sets U and V such that the sum of the elements is U is equal to the sum of the elements in V (and therefore equal to half the sum of the elements in L); or (B) the statement that no such partition exists.

For example, given the input [1, 4, 6, 14, 17, 20] the output could be {1, 4, 6, 20}, {14, 17}, since both partitions add up to 31. Given the input [3, 4, 6, 14, 17, 20] the output would be "FALSE" since no such partition exists. Consider the following solution to this problem using state space search: Let M = the sum of the elements in L.

Problem 2

Show the result of carrying out alpha-beta pruning on the game tree shown below.

Problem 3

Convert the following sentence to CNF:
(P <=> Q) => R.

Problem 4

Trace the workings of the Davis-Putnam procedure on the set of clauses.
1. ~P V Q V R
2. P V ~Q
3. P V ~R
4. ~P V ~Q V S
5. ~Q V R V ~S
6. ~R V ~S
7. ~A V P.
8. ~A V R.

Problem 5

Let G be a directed graph. A Hamiltonian path through G is a path through G that includes every vertex exactly once. For example, in the graph shown below, the path [B,C,F,D,A,E] is a Hamiltonian path.

Suppose that we want to build a compiler that turns a Hamiltonian path problem into a problem of satisfiability, which can then be input to Davis-Putnam. This can be done as follows: Let N be the number of vertices in the graph = the number of vertices in the desired path. For each vertex V and number I between 1 and N, construct a propositional atom V_I, meaning that vertex V is in place I in the target path.

Show how the following three types of constraints can be expressed: