Family Name: Other Names: Signature: Student Number: This PAPER is NOT to be retained by the STUDENT

The University Of New South Wales

COMP1711 Final Exam (skeleton) Higher Computing 1A

July 2004

Time allowed: 3 hrs Total number of questions: 22 Total number of marks: 105 No examination materials permitted.

You must hand in this entire exam paper and the answer booklet. Failure to do so will result in zero marks for the subject and a possible charge of academic misconduct. Ensure that you fill in all of the details on the front of the answer booklet, and then SIGN the booklets. Do the same for this pink question paper. Do not use red pen or pencil in this exam. There is one mark for following the examination instructions.

Examiner’s Use Only

Inst A 12 13 14 15 16 C D Total

Part A: Multiple Choice Questions

Answer the questions in this part by circling the correct answer. For each correct answer you earn 3 marks. There is no penalty for incorrect answers.

Question 1

Which of the following lines will generate a syntax error message:

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 2

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 3

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 4

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 5

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 6

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 7

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 8

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 9

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 10

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Question 11

blah

[A] blah
[B] blah
[C] blah
[D] blah

[E] All of the above

Part B: Short Answer Questions

Answer these questions in the spaces provided on this pink question paper. DO NOT answer these questions in an answer booklet!

Write your answers clearly. Keep your answers neat and very brief. Messy or long answers will not be marked.

Question 12

(2 marks)

Blah Blah Blah?

Question 13

(3 marks)

Blah Blah Blah?

Question 14

(5 marks)

A programmer wrote the following Haskell function without commenting it, and was then hit by a train before they could explain it to you. What does nb do?

nb 0 = 5
nb y = nb (nb (y - 1))

Note - your answer should say what the output of nb is (i.e. its overall effect), it should not be a description of how the output is calculated.

Answer:

Question 15

(2 marks)

Give a possible definition for the algebraic type used to represent trees in Question 10

Question 16

(8 marks) blah blab blah

lines of code
lines of code
lines of code
lines of code
lines of code
lines of code
lines of code
lines of code
lines of code

Briefly state what the worst case is:

Part C

Answer this part in your Part C answer booklet. Start each question on a new page.

Make your answers as clear and easy to understand as possible. Provide type definitions and brief comments where necessary. Confusing or illegible solutions will lose marks.

If you do not wish your answer for a question to be marked clearly record 1 mark for that question on the front of your Part C answer booklet. If you do this your answer for that question will not be marked.

In this part you may not import or use any library modules.

Question 17

(5 marks)

(a) Write your own version of the builtin function pootle, replacing the ???? with appropriate Class restriction(s).

(b) Blah blah blah

     pootle :: (????) => a -> b

Question 18

(6 marks) Write a function

iraqfreedom :: [[a]] -> b

which returns a blah blah blah.

Question 19

(8 marks) Suppose you wish to write your own version of the Haskell function patriotact.

Write a Haskell function myPatriotact,

myPatriotact :: a -> b

which takes as input a blah, and which returns a blah blah blah.

You may not use the Haskell function patriotact in your solution (obviously!)

Question 20

(8 marks) Write a function

wmd :: Integer -> Integer -> Integer

to compute the inverse of a mod b

For a bonus mark briefly explain (in no more than two lines) how blah blah, and show how you could alter your function to overcome this.

Part D

Answer this part in the answer booklet.

Partial solutions (i.e. attempts worth less than 50%) will score no marks in this part. If you do not wish your answer for an entire question to be marked record 1 mark for that question on the front of the answer booklet. If you do this your answers for all sub-questions of that question will not be marked.

Sub-questions are not of equal value.

Your solutions must be clear, elegant and easy to understand. In this part confusing or difficult to understand solutions will score no marks.

Question 21

(14 marks)

blah blah blah

(a) Neatly draw and label a small diagram illustrating blah blah blah.

(b) Implement the function moralRights in the Disney module below blah.

     module Disney where
     lines of code
     lines of code
     lines of code

(c) Write a function randoms :: Integer -> [Integer] in the Disney module which returns blah blah blah.

Question 22

(10 marks)

This question has two subquestions - you are only to answer ONE of them. You may choose which one. The first one is only worth 4 marks, the second is worth 10 marks.

(a) blah blah blah

(b) blah blah blah