CS 250 Exam 2.

Read the directions!!! Due no later than Friday May 11 at 5:00 p.m.

You may self-schedule this test in any 4 hour window until the test due date. Once you have begun reading the questions your 4 hours will have begun. Do not discuss the test with anyone except me, even after you are finished! You are allowed to use the lab machines for the programming questions (but not to search the web). You may use the textbook and your course notes, but no other outside sources of information. Your answers will be judged for clarity, conciseness and well-supported arguments. Remember, you start the exam with 0 points and I am not a mind reader, so all points are earned. I much prefer typed to hand-written work since some people's hand-writing (like my own) is very hard to read.

For the programming questions please email me your solutions as soon as your four hours has expired.

Please print out the entire test, and sign and turn in the following along with your test.

I have neither given nor received aid on this test. I have followed the guidelines described in the test for the number of hours allotted and for using outside sources.

Signed ________________ Go back and read the directions again!

  1. Write a Prolog function that takes a list and splits it into two equal halves. The call splitlist(A, B, C) should take list A and divide it into two halves where B is the first half of A and C is the second half of A. E.g. splitlist([1, 3, 5, 7], B, C). should return B = [1, 3], C = [5, 7]. In the case of odd-length lists, you may put the extra element in either list as long as you are consistent in your choice.
  2. Write two lisp functions that have the same functionality of the previous question. (firsthalf A) should return a list that consists of the first half of list A. (secondhalf A) should return a list that consists of the second half of list A.
  3. Write two methods for the Java List class that have the same functionality as in the previous questions. Assume the List class is implemented as a Singly Linked List and simply stores the head in a variable called head. Further you may assume that ListNodes have methods next(), and setnext(ListNode x) in addition to several constructors. Assume that the List class contains the usual methods (isEmpty, length, etc.). Note: your methods should not alter the original list.
  4. Discuss the differences in your answers to each of the three previous questions and how those differences reflect the different programming paradigms of the languages involved. Rank the three questions in order of difficulty and explain your ranking.
  5. Discuss how a list data structure might be implemented in a production system language such as Soar.
  6. Read the directions again.
  7. Give a reasoned explanation of why the Imperative/Object Oriented programming paradigm is currently dominant. Do you think this dominance is justified? Support your answer with examples.
  8. How did Harry Potter get a lightning bolt shaped scar on his forehead?