CS 3304 Homework Assignment 7

25 Points
Due: 03/24 at the start of class

Note: The following instructions are repeated from the Homework Dates/Guidelines page:

Your solutions for each homework assignment must be prepared with a word processor (e.g., LaTeX or Word), and are due at the beginning of class on the due date specified unless otherwise noted on the assignment itself.

Note that all homework problems taken from the text are in the Problem Sets. Do not turn in solutions to Review Questions by mistake!

Also, remember that the 5th Edition text includes a new chapter--Chapter 4. All chapter numbers in homework assignments are from the 5th Edition, so students with earlier versions of the text must remember that in their books, the chapter numbers are off by one. If you have an earlier version of the text, you are still responsible for solving the correct problems.

Complete each of the following problems:

  1. This question is based on Chapter 16, Problem 6 (Chapter 15 in 4th ed.).

    Several of the tutorial links on the Prolog page of our web site contain implementations of a union predicate that takes three list arguments. This operation is analogous to the one you wrote in Scheme (Chapter 15, question 3).

    1. Select one of the union implementations from a tutorial, or write your own. In your homework writeup, thoroughly annotate this implementation of union. Do this using Prolog comments embedded in your code listing. First, explicitly describe the role of each parameter to the predicate. Then, for each separate rule in your definition of union, describe the condition(s)/case(s) for which that rule is designed. Then, within the body (right-hand side) of each rule, list each clause on a separate line, and provide a description of exactly what purpose that clause serves or what action it performs in achieving the aim of the rule it appears in.

    2. Compare and contrast your Prolog implementation of union with the Scheme implementation you wrote for homework assignment #4. Identify the strengths and weaknesses of each, and point out what you think are the most critical differences between the capabilities of the two solutions.

  2. Repeat question #3 from homework assignment #5, in Prolog instead of Scheme. Document the use and meaning of each parameter to the predicate you create.

  3. Chapter 7, Problem 10 c, d, and e (Chapter 6 in 4th ed.)