XML

kent logo

CO538 Anonymous Questions and Answers

This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course.

When asking questions, please do not simply paste in your code and ask what is wrong with it, as these types of question are hard to answer in a public forum (resulting in either no answer, or an answer which will only be of use to the person asking the question). In many cases, a question about code can be formulated in general terms. For example, if you have an `IF' block that results in an `incorrect indentation' error, you might ask, ``what is the correct syntax for an occam `if' statement ?''. Questions of this form are easier to answer, and are meaningful to all.

Questions that are not suitable for these public pages (i.e. those that contain assignment-specific code), should be mailed to your seminar-leader.


Question 41:

In past exam paper 1998 question 3(b), it says that without writing an ALT construct, explain how a buffered channel with a capacity of 100 can be implemented. I'm interested in how can an ALT construct implement a buffered channel,please? Thank you.

Answer 41:

You stick a buffer process in the channel - see slides 6-11 to 6-13 and slides 6-17 to 6-17. The answer to the question asked in the paper, of course, is given by slide 5-7 (or 6-17).

Keywords: exams , buffered-channel

Referrers: Question 123 (2003)


Question 42:

Are the answers to previous years exams available to us?

Answer 42:

This question seems to have been asked about most courses. I'm afraid the answer here is still the same - no.

The seminar groups spent most of Lent term working through past exam questions ... where something much more valuable than the answers was made available. If you didn't attend, find people who did and ask for help. Explaining things to others will help them revise as well.

Keywords: exams , model-answers

Referrers: Question 126 (2004)


Question 43:

Is it ok to write code in pencil in the exam?

Answer 43:

Yes - so long as it is visible.

Keywords: exams


Question 44:

What do these mean??

  [array FROM s FOR 1][i]
  [[[array FROM s FOR 1] FOR i][j], 42]

Answer 44:

If X is an array, then X[i] refers to its ith. index element.

Well, [X FROM start FOR n] is an array - it represents the slice of the array X from index start for the next n elements inclusive. [This is explained in the last paragraph of Section 5 of "The occam Checklist" in your course notes.] Of course, if that slice takes us outside the index bounds of the array, that generates a run-time error.

So:

  [X FROM start FOR n][i]

is just the ith. index element of the array [X FROM start FOR n], which is the (start + i)th. index element of the array X, so long as i is in the bounds of [X FROM start FOR n] - i.e. so long as 0 <= i < n. Therefore:

  [array FROM s FOR 1][i]

is only legal if i is zero ... in which case it is the same as element array[s].

If start is zero, then [X FROM start FOR n] may be written as just [X FOR n]. So:

  [[array FROM s FOR 1] FOR i]

is only error free if i is zero or one. If the former, then the above represents a zero-length array for which any further indexing or slicing will throw a run-time error. If the latter, the above represents the same one-length array slice as before - i.e. it's the same as:

  [array FROM s FOR 1]

Continuing with the only legal assumption (that i is one), then:

  [[array FROM s FOR 1] FOR i][j]

equals:

  [array FROM s FOR 1][j]

As considered before, the above is only legal if j is zero, in which case it equals:

  array[s]

So, the original expression:

  [[[array FROM s FOR 1] FOR i][j], 42]

is only legal if i is one and j is zero - in which case, it equals:

  [array[s], 42]

So long as s is a legal index of the array array, this is a literal expression of either a two-element array (assuming that array is an array if integers) or a two-field RECORD type. See the answer to Question 45 (2002) for (non-examinable) information on RECORD types.

I'd not ask anyone to work through such a tortuous example in an exam!

Keywords: arrays , array-segments

Referrers: Question 65 (2004) , Question 104 (2003)


Question 45:

What is a RECORD used for?

Answer 45:

This is not examinable. See:

  \\raptor\files\courses\co516\etc\records.txt

if you want some information.

Keywords: record-types

Referrers: Question 44 (2002)


Question 46:

How strict will you be with indentation when marking our exams?

Answer 46:

Indenting handwritten code is no burden. I need to be able to see structure in your code and indentation makes that plain. So, badly indented code that is hard to follow definitely means fewer marks - the same as for anything that is hard to comprehend. Of course, I'm not going to be counting spaces and making sure everything lines up exactly - it just needs to line up roughly and be neat.

Having said that, I'm not going to penalise minor syntax errors - e.g. getting the layout of an IF a bit wrong, some missing colons, some missing SEQs etc.. Also, don't be afraid to cross things out or insert missed out lines by writing them on the script, drawing an approx. circle around it and drawing an arrow from that circle to where the enclosed code should be inserted ... just don't let it get too scrappy! If you don't have room to write missed-out code on the page it needs to be inserted, draw an 'A' (or 'B', 'C', etc.) in a circle with an arrow to the insert point - write the missing code on another page and label it with the 'A' (or 'B', 'C', etc.) again in a circle. It just needs to be obvious what you intend.

A powerful scheme is to use the "fold" notation shown in some of the course slides - e.g.

  SEQ
    ...  initial bit
    ...  second bit
    WHILE running
      ALT
        ...  deal with in?
        ...  deal with kill?

That shows the overall structure. Then, an in any order, you could write out the "folded" bits - e.g.

  "initial bit"

    out.string ("Hello world ...", 0, screen)
    count := 0
    SEQ i = 0 FOR SIZE x
      x[i] := 42
    running := TRUE

and:

  "deal with kill?"

    BOOL any:
    kill ? any
      running := FALSE

or whatever. This is just a more pre-planned way of doing the trick with the forward references via the letter-in-bubbles above.

Summary: I need to see that you have mastered the concepts sufficiently to apply them to express logic necessary to design and implement solutions to specific problems. I'm not demanding perfect syntax ... that's trivial to get right with the aid of a compiler. I'm looking for clear structure and semantics - the simpler the better ... remember Ockham's Razor ...

Keywords: exams

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:23 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.