datatype BOOL = VAR of string | NOT of BOOL | AND of BOOL*BOOL | OR of BOOL*BOOL;The constructor VAR is used to represent named boolean variables, and NOT, AND and OR are used to represent the corresponding boolean operators.

Define a function that will return a list of the distinct names used in a given boolean expression. [4 marks]

A context is represented by a list of strings corresponding to the boolean variables that are set to true. All other variables are deemed to be set to false. Define a function that will evaluate a given boolean expression in a given context. [3 marks]

incorporate your two functions into a program that will determine whether a given boolean expression is true for all possible settings of its variables. [3 marks]

- to simulate the effect of the EXIT statement; [5 marks]
- to skip to the next iteration of the loop. [5 marks]

- What are the advantages of using a high-level language for writing programs? [7 marks]
- Why must some parts of the code which makes up an executable binary program typically have to be written in assembly language ? Who typically writes these parts and where are they normally stored in the system? [3 marks]

`rotations [1,2,3] = [[1,2,3],[2,3,1],[3,1,2]]`

The order in which the rotations occur is unimportant. [10 marks]

Carefully explain how your function works and estimate the time complexity of your solution. [10 marks]

The decimal representation of a real number in the range 0 to 1 is to be represented
as an infinite sequence of the decimal digits following the decimal point
(O.d_{1}d_{2} ... ).
Define a function `mknumb` which which when applied to the digit function dig will
construct a lazy list of these digits
where the i^{th} digit (d_{i}) is given by `dig i`.
[5 marks]

Suppose we have an infinite sequence of such numbers [r_{1},r_{2},...], in which the
digits of the decimal expansion of r_{i} are given by
the digit function f_{i}, and that
the collection of digit functions is represented by the lazy list
[f_{1},f_{2} .... ]. Define
suitable datatypes for the list of numbers and the list of digit functions. [5 marks]

Define a function `newnumb` which when given the lazy list of digit functions will
yield a lazy list of digits that have the property that its i^{th} digit
differs from the i^{th} digit of r_{i}. [5 marks]

PROCEDURE Stats () = VAR m, v := 0.0; BEGIN WITH n = IO.GetInt (), a = ARRAY [1. .n] OF REAL DO FOR i := 1 TO n DO a[i] := IO.GetReal () END; FOR i := 1 TO n DO INC (m, a[i]) END; m := m / n; FOR i := 1 TO n DO INC (v, (a[i]-m)*(a[i]-m)) END; v := v / n; RETURN RECORD {m, v}; END; END Stats;Explain, to the extent that you can reconstruct them, the programmer's intentions. [5 marks]

Comment on the legality of the code and indicate what the Modula-3 compiler's response would be to it. [5 marks]

How would you correct the procedure -

- following the external data format and internal data structure and algorithm intended by the programmer; [5 marks]
- re-writing it completely from scratch, possibly even having a different external data format (which should be specified). [5 marks]

Give type definitions and default method implementations for this queue object. [20 marks]

- How does a loaded program in a general purpose timesharing computer gain access to input and output streams provided by the operating system? [5 marks]
- What happens when the program is ready to receive the next data from a keyboard input stream and no key press is ready? [5 marks]
- A CPU intensive program will tend to run for long periods of time without making requests of the operating system. What happens to other users programs when someone runs a CPU intensive program? [5 marks]
- What can be done for a shared output device such as a printer or plotter to ensure civilised results when two or more users try to use it at once? [5 marks]

- The term microprocessor. [3 marks]
- The term programming model. [3 marks]
- The effects (or lack of them) on the programming model of having microprocessors imbedded in peripheral devices of a computer. [6 marks]
- A programming model of an overt multiprocessor machine. [6 marks]
- What type of system in production today is likely to have exactly one microprocessor inside? [2 marks]