# Assignments

The following table indicates assignments and due dates for Computer Science 302. Unless otherwise indicated,

• assignments related to program verification are due weekly, usually on Fridays,
• other assignments are due on Mondays,
• extensions to due dates will be granted only in advanced,
• textbook references are to course textbooks,

• collaboration is allowed on some assignments and not on others; specific rules of collaboration are shown for each assignment.

Due Date Text Chapter Collaboration Problems
January 29 Gries1 No 1.3
Gries2 No 2.5, 2.6cegk
January 31 Gries1 Yes 1.4
Gries2 Yes 2.6fhjl
Mitchell1 Yes Problem 1 (below)
February 2 Gries4 No 4.1.3, 4.2.6a-bjkm, 4.4.2, 4.5.2ac
February 9 Gries5 No 5.1.1ace, 5.1.2bfg, 5.2.2, 5.2.3
February 23Gries6 No 6.2.1deg
March 2Gries7 No 7.1acef, 7.2(1,3,5), 7.4, 7.5
Gries8 No 8.1, 8.3, 8.6
March 9 Gries9 No 9.1.1ace, 9.2.2, 9.2.3bdf, 9.2.4ace, 9.3.1ace
March 12 Gries10 No 10.1, 10.3, 10.5, 10.6, 10.8
March 16 Gries11 No 11.1, 11.8, 11.9, 11.10, 11.12
April 6 Gries14 No 14.1abd
April 13 Gries16 No 16.2.2, 16.2.3
April 27 Gries16 No 16.3.1, 16.3.5, 16.3.7
April 30 [Prolog] Yes Problem 2, Problem 3 (below)
May 7 Gries16 No 16.5.2, 16.5.5, 16.5.9
[Prolog] No Problem 4, Problem 5 (below)
Due Date Text Chapter Collaboration Problems

Problem 1: Find a partial function that has the following three properties:

• the function is well-defined for at least 2 values,
• the function is undefined for at least 2 values, and
• the function does not terminate for at least 2 values.
Note: In the preferred solution to this problem, "at least 2 values" would be replaced by "an infinite number of values" in each case above.

Problem 2: Define Prolog relations to determine if a list has an even number of elements.

Problem 3: Define Prolog relations to determine if a list:

1. is a permutation of another.
2. is formed by merging two lists.

Problem 4: Write a Prolog program that succeeds if the intersection of two given list parameters is empty.

Problem 5: Draw Prolog search trees for the query:

```
?- reverseList([a, b, c, d], W).
```
where reverseList is defined by the rules:
```a.
reverseList([ ], [ ]).
reverseList([A|X], Z) :- reverseList(X, Y),append(Y, [A], Z).
```
```b.
reverseList(X, Z) :- rev(X, [ ], Z).
rev([ ], Y, Y).
rev([A|X], Y, Z) :- rev(X, [A|Y], Z).
```

This document is available on the World Wide Web as

```http://www.math.grin.edu/~walker/courses/302.sp01/assignments.html
```

created December 29, 1999
last revised April 23, 2001