Part I Written Assignment

1.Describe how a multiple-processor machine could be used to implement resolution. Could Prolog, as currently defined, use this method?

2.Explain two ways in which the list-processing capabilities of Scheme and Prolog are similar.

3.In what way are the list-processing capabilities of Scheme and Prolog different?

4.Suppose you want to write a method that prints a heading on a new output page, along with a page number that is 1 in the first activation and that increases by 1 with each subsequent activation. Can this be done without parameters and without reference to nonlocal variables in Java? Can it be done in C#?

5.Consider the following program written in C syntax:

void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}

void main() {
int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}

For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three calls to swap?

  • Passed by value
  • Passed by reference
  • Passed by value-result

6.Consider the following program written in C syntax:

void fun (int first, int second) {
first += first;
second += second;
}

void main() {
int list[2] = {1, 3};
fun(list[0], list[1]);
}

For each of the following parameter-passing methods, what are the values of the list array after execution?

  • Passed by value
  • Passed by reference
  • Passed by value-result

Part 2 Programming Assignment

1.Write a Prolog program that finds the maximum of a list of numbers.

2.Write a Prolog program that returns a list containing the union of the elements of two given lists.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.