ttth Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable
Question:
ttth
Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable function e(n, x) = fn(x), [7 marks] Hence prove that the set of all recursive bags cannot be recursively enumerated. [3 marks] (b) A bag B is finite if there is X N such that fB(x) = 0 for all x > X. Show that the set of all finite bags is recursively enumerable.
Let x be the floating-point representation of a number x. Define the absolute error and relative error in representing x by x . How are these errors related? Let x1, x2 be two numbers. Find expressions for (a) the absolute error in representing x1 + x2 (b) the relative error in representing x1.x2 ) Assume that the numbers 1 and 2 are represented exactly. Find an expression for the absolute error in calculating 2x + 1. [2 marks] In an iterative calculation the number y is an improved value of x, derived from the assignments p := x/2 + 1 q := x 2 y := p + 1/q If x is the absolute error in representing x, find an expression for the absolute error y in representing y. [6 marks] What is the approximate relative error y in representing y when x = 2.01?
Assume a simple paging system with 232 bytes of physical memory, 248 bytes of logical address space and pages that are 220 bytes in size. Further assume that each page table entry contains 4 bits indicating protection and validity of the entry. (i) How many bits are used for the frame number and how many for the frame offset? [1 mark] (ii) What is the total size of the page table in number of bits? [2 marks] (iii) Assume that the working set of a typical process is fixed throughout the process lifetime and consists of 20 pages. How many entries would you suggest for the Translation Lookaside Buffer (TLB) for this system? What would its total size be in number of bits? Explain your answer. [4 marks] (iv) Further assume that TLB search time is 20ns, TLB hit ratio is 80% and memory access time is 100ns. How many page table levels would you need to achieve an effective access time of 160ns, and why? [3 marks] (b) (i) A Unix i-node has 12 disk addresses for direct disk blocks and three addresses for single, double, and triple indirect blocks. If each indirect block contains 256 disk addresses, what is the maximum file size supported by this system? Assume disk blocks of 4KB. [3 marks] (ii) Assume that you are user1 in a Unix file system and that you need to read the file /home/user1/test/test1.html which is stored in 4 disk blocks. Further assume that the / directory i-node is kept memory and each i-node and directory file fits in one disk block. How many disk accesses are required to read test1.html? Explain your answer. [4 marks] (iii) Assume that user1 wants to read /home/user1/test/test2.html immediately after reading /home/user1/test/test1.html. Further assume that file test2.html is stored in 4 disk blocks. How many disk accesses are required to read test2.html? Explain your answer. [3 marks]
) Assume a 32-bit architecture with hardware support for paging, in the form of a translation lookaside buffer (TLB), but no hardware support for segmentation. Assume that the TLB is shared rather than flushed on process switching and that the operating system designers are supporting "soft" segments. (i) In addition to page number and page base, what fields would you expect to find in each TLB register? How would each of these be used? [4 marks] (ii) What fields would you expect to find in a process page table? How would each of these fields be used? [6 marks] (b) (i) Outline the function of a timing device. [2 marks] (ii) Why are timers essential in multiprogramming operating systems? [2 marks] (iii) Explain the operation of a multi-level feedback queue in process scheduling. [6 mar
The Java class below defines a queue data structure with a fixed capacity. public class F boolean enqueue(int x) false; mData[mTail]=x; mTail++; return true; } public int dequeue() { if (mTail==mHead) return -1; int v=mData[mHead]; mHead++; return v; } } (a) Explain the risks posed by the lack of access modifiers specified on the state. Which access modifier is appropriate for these entities? [3 marks] (b) Discuss the choice to signal enqueue and dequeue errors using return values of false and -1, respectively. Suggest a better alternative and modify enqueue and dequeue to use it. [5 marks] (c) Explain how an enqueue operation on a FixedCapacityQueue object could fail with an error even when there are fewer items in the queue than the assigned capacity of the object. Show how to fix this. [3 marks] (d) Rewrite the class to use Java's Generics so that it can be used to represent queues of arbitrary objects (Integers, Strings, etc). Use the java.util.ArrayList class instead of int[] for the type of mData. [4 marks] (e) Explain why it was necessary to replace the int[] type of mData in part (d), and why ArrayList does not suffer from the same issue. [5 marks]
(a) Explain the risks posed by the lack of access modifiers specified on the state. Which access modifier is appropriate for these entities? [3 marks] (b) Discuss the choice to signal enqueue and dequeue errors using return values of false and -1, respectively. Suggest a better alternative and modify enqueue and dequeue to use it. [5 marks] (c) Explain how an enqueue operation on a FixedCapacityQueue object could fail with an error even when there are fewer items in the queue than the assigned capacity of the object. Show how to fix this. [3 marks] (d) Rewrite the class to use Java's Generics so that it can be used to represent queues of arbitrary objects (Integers, Strings, etc). Use the java.util.ArrayList class instead of int[] for the type of mData. [4 marks] (e) Explain why it was necessary to replace the int[] type of mData in part (d), and why ArrayList does not suffer from the same issue. [5 marks]
Give a brief summary of the main syntactic constructs found in the programming language Smalltalk. Other languages often have the conditional constructs if-then-else and while. Show how these two constructs can be defined in Smalltalk. [8 marks] Illustrate the use of Smalltalk by showing how you would define a method to compute the factorial of an integer. [8 marks] Although Smalltalk was originally designed to be an interpretive language, modern implementations are dramatically more efficient. Briefly outline what techniques might have been used to make this improvement.
(a) Brieflfly explain the difffferences between combinational and sequential logic.
[2 marks]
(b) With the aid of appropriate diagrams, brieflfly explain the operation of Moore
and Mealy fifinite state machines and highlight their difffferences. [6 marks]
(c) The state sequence for a binary counter is as follows:
The counter is to be implemented using four synchronously clocked D-type
flflip-flflops.
(i) Draw a state table for the counter, showing the required D inputs.
[4 marks]
(ii) Find expressions for the D inputs, making use of unused states if
appropriate. [6 marks]
(iii) What problem could occur when the counter circuit is powered-up? Give
two possible general methods for overcoming the problem. [2 marks]
2CST.2008.2.3
2 Digital Electronics
(a) With the aid of relevant diagrams, show the effffect on the output of a
combinational logic circuit of a:
(i) static hazard;
(ii) dynamic hazard. [3 marks]
(b) Simplify the following expressions using Boolean algebra:
[4 marks]
(c) Given:
F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D
(i) Show using a Karnaugh map that F can be simplifified to
F1 = A . B + A . B + A . C + B . C . D
[2 marks]
(ii) Show that there are a total of four possible expressions for F. [3 marks]
(iii) Show how F1 can be implemented using NAND gates and draw the circuit
diagram. Assume that complemented input variables are available.
[2 marks]
(iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaugh
map-based approach. [2 marks]
(v) Now implement F1 assuming that only 2-input NAND gates are available.
[4 marks]
3 (TURN OVER)CST.2008.2.4
SECTION B
3 Discrete Mathematics
Let X and Y be sets. You are reminded that a relation from X to Y is a subset of
the product X Y .
(a) Explain what it means for a relation f from X to Y to be a function, an
injection and a surjection from X to Y . [4 marks]
(b) A bijection from X to Y is defifined to be a function from X to Y which is
both an injection and a surjection. Prove that a function f from X to Y is a
bijection iffff it has an inverse function g, i.e. g is a function from Y to X such
that g f = idX and f g = idY .
[Remember to prove both the "if" and "only if" parts of the assertion.]
[12 marks]
(c) Describe, without proof, a bijection from P(X Y ) to (X P(Y )) and its
inverse. [4 marks]
4CST.2008.2.5
4 Discrete Mathematics
Let I be a non-empty subset of the natural numbers N = {1, 2, 3, }.
The set S is defifined to be least subset of N such that
I S, and
if m, n S and m < n, then (n m) S.
Defifine h to be the least member of S. This question guides you through to a proof
that h coincides with the highest common factor of I, written hcf (I), and defifined
to be the natural number with the properties that
hcf (I) divides n for every element n I, and
if k is a natural number which divides n for every n I, then k
divides hcf (I).
[Throughout this question you may assume elementary facts about division.]
(a) The set S may also be described as the least subset of N closed under certain
rules. Describe the rules. Write down a principle of rule induction appropriate
for the set S. [4 marks]
(b) Show by rule induction that hcf (I) divides n for every n S. [3 marks]
(c) Let n S. Establish that
if p.h < n then (n p.h) S
for all non-negative integers p. [5 marks]
(d) Show that h divides n for every n S. [Hint: suppose otherwise and derive a
contradiction.] [5 marks]
(e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).
[3 marks]
5 (TURN OVER)CST.2008.2.6
SECTION C
5 Probability
(a) Suppose that X is a random variable whose value r is distributed Geometric(p).
Write down the expression for the probability P(X = r). [3 marks]
(b) By using a suitable generating function or otherwise, show that the expectation
E(X) = (1 p)/p. [5 marks]
The University Computing Service defifine a serious power outage as a power cut that
lasts for longer than their Uninterruptable Power Supply equipment can maintain
power. During the course of an academical year the number of serious power outages
is a random variable whose value is distributed Geometric(2/5). Accordingly, the
probability of having no serious power outages during the course of a year is 2/5.
(c) The University is investigating a compensation scheme which would make no
payment over the year if the number of serious power outages were zero or
one but which would pay the Computing Service 1000 for every such outage
(including the fifirst) if the total number of serious power outages in a year were
two or more. Determine the expected annual sum that the Computing Service
would receive. [8 marks]
(d) To what value would the parameter of the Geometric Distribution have to be
changed (from 2/5) for the expected annual sum to be 750? [4 marks]
6 Probability
(a) Give a brief account of the Trinomial Distribution and include in your
explanation an expression that is equivalent to n
!
r!(n
r)! prqnr for the Binomial
Distribution. [5 marks]
(b) An indicator light can be in one of three states: OFF, FLASHING and ON, with
probabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lights
whose states are mutually independent.
(i) What is the probability that all fifive lights are OFF? [3 marks]
(ii) What is the probability that three lights are OFF, one light is FLASHING
and one light is ON? [3 marks]
(iii) What is the probability that three or more lights are OFF and at most one
is ON? [9 marks]
All results must be expressed as fractions.
6CST.2008.2.7
SECTION D
7 Software Design
Software systems often incorporate structural representations of the application
domain in which they operate. For example, a vehicle control system should be
aware of the fact that the car has precisely four wheels. This kind of information
must be captured, encoded and tested at each stage of the software design process.
Using the number of wheels in a car as a simple example, describe relevant design
activities and products at each of the following phases of a software project:
(a) inception; [4 marks]
(b) elaboration; [4 marks]
(c) construction; [4 marks]
(d) transition; [4 marks]
(e) system operation. [4 marks]
8 Regular Languages and Finite Automata
(a) Explain what is a context-free grammar and the language it generates.
[4 marks]
(b) What does it mean for a context-free grammar to be regular? Given any
deterministic fifinite automaton M, describe a regular context-free grammar
that generates the language of strings accepted by M. [4 marks]
(c) Construct a non-deterministic fifinite automaton with -transitions whose
language of accepted strings is equal to the language over the alphabet {a, b, c}
generated by the context-free grammar with non-terminals q0 and q1, whose
start symbol is q0 and whose productions are q0 abq1, q1 , q1 q0 and
q1 abc. [4 marks]
(d) Is every language generated by a context-free grammar equal to the
set of strings accepted by some non-deterministic fifinite automaton with
-transitions? Justify your answer. (Any standard results about regular
languages you use should be carefully stated, but need not be proved.)
[8 marks]
7 (TURN OVER)CST.2008.2.8
9 Professional Practice and Ethics
(a) The British Computer Society Code of Conduct has four sections. What kind
of professional conduct does each section cover, and how does each of these
kinds of conduct benefifit the profession and its members? [8 marks]
(b) True or False questions:
(i) A User can provide occasional use of the University computer system for
a friend who is a temporary visitor.
(ii) Circumstances that mitigate minor infractions of the rules promulgated
by the Information Technology Syndicate include, among other things,
inebriation.
(iii) Appropriate use of the Cambridge University Data Network (CUDN)
means bona fifide academic activity plus a low level for private purposes.
(iv) Small amounts of commercial activity are acceptable as long as the User
is acting in a private capacity.
[4 marks]
(c) The IT industry is increasingly aware of its own environmental impact.
Describe at least one environmental problem to which the industry contributes
and how, as an IT professional, you can help to solve this problem. [4 marks]
(d) "Social engineering is a greater threat to computer security than computer
cracking software." What is social engineering and what measures can be
taken to guard against it? [2 marks]
(e) What is copyleft and how is it used to protect free, open-source, software?
(a) Brieflfly explain the difffferences between combinational and sequential logic.
[2 marks]
(b) With the aid of appropriate diagrams, brieflfly explain the operation of Moore
and Mealy fifinite state machines and highlight their difffferences. [6 marks]
(c) The state sequence for a binary counter is as follows:
The counter is to be implemented using four synchronously clocked D-type
flflip-flflops.
(i) Draw a state table for the counter, showing the required D inputs.
[4 marks]
(ii) Find expressions for the D inputs, making use of unused states if
appropriate. [6 marks]
(iii) What problem could occur when the counter circuit is powered-up? Give
two possible general methods for overcoming the problem. [2 marks]
2CST.2008.2.3
2 Digital Electronics
(a) With the aid of relevant diagrams, show the effffect on the output of a
combinational logic circuit of a:
(i) static hazard;
(ii) dynamic hazard. [3 marks]
(b) Simplify the following expressions using Boolean algebra:
(i) X = (A + B + A . B).(A + B). A . B
(ii) Y = (A + B + A . B). C
[4 marks]
(c) Given:
F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D
(i) Show using a Karnaugh map that F can be simplifified to
F1 = A . B + A . B + A . C + B . C . D
[2 marks]
(ii) Show that there are a total of four possible expressions for F. [3 marks]
(iii) Show how F1 can be implemented using NAND gates and draw the circuit
diagram. Assume that complemented input variables are available.
[2 marks]
(iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaugh
map-based approach. [2 marks]
(v) Now implement F1 assuming that only 2-input NAND gates are available.
[4 marks]
3 (TURN OVER)CST.2008.2.4
SECTION B
3 Discrete Mathematics
Let X and Y be sets. You are reminded that a relation from X to Y is a subset of
the product X Y .
(a) Explain what it means for a relation f from X to Y to be a function, an
injection and a surjection from X to Y . [4 marks]
(b) A bijection from X to Y is defifined to be a function from X to Y which is
both an injection and a surjection. Prove that a function f from X to Y is a
bijection iffff it has an inverse function g, i.e. g is a function from Y to X such
that g f = idX and f g = idY .
[Remember to prove both the "if" and "only if" parts of the assertion.]
[12 marks]
(c) Describe, without proof, a bijection from P(X Y ) to (X P(Y )) and its
inverse. [4 marks]
4CST.2008.2.5
4 Discrete Mathematics
Let I be a non-empty subset of the natural numbers N = {1, 2, 3, }.
The set S is defifined to be least subset of N such that
I S, and
if m, n S and m < n, then (n m) S.
Defifine h to be the least member of S. This question guides you through to a proof
that h coincides with the highest common factor of I, written hcf (I), and defifined
to be the natural number with the properties that
hcf (I) divides n for every element n I, and
if k is a natural number which divides n for every n I, then k
divides hcf (I).
[Throughout this question you may assume elementary facts about division.]
(a) The set S may also be described as the least subset of N closed under certain
rules. Describe the rules. Write down a principle of rule induction appropriate
for the set S. [4 marks]
(b) Show by rule induction that hcf (I) divides n for every n S. [3 marks]
(c) Let n S. Establish that
if p.h < n then (n p.h) S
for all non-negative integers p. [5 marks]
(d) Show that h divides n for every n S. [Hint: suppose otherwise and derive a
contradiction.] [5 marks]
(e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).
[3 marks]
5 (TURN OVER)CST.2008.2.6
SECTION C
5 Probability
(a) Suppose that X is a random variable whose value r is distributed Geometric(p).
Write down the expression for the probability P(X = r). [3 marks]
(b) By using a suitable generating function or otherwise, show that the expectation
E(X) = (1 p)/p. [5 marks]
The University Computing Service defifine a serious power outage as a power cut that
lasts for longer than their Uninterruptable Power Supply equipment can maintain
power. During the course of an academical year the number of serious power outages
is a random variable whose value is distributed Geometric(2/5). Accordingly, the
probability of having no serious power outages during the course of a year is 2/5.
(c) The University is investigating a compensation scheme which would make no
payment over the year if the number of serious power outages were zero or
one but which would pay the Computing Service 1000 for every such outage
(including the fifirst) if the total number of serious power outages in a year were
two or more. Determine the expected annual sum that the Computing Service
would receive. [8 marks]
(d) To what value would the parameter of the Geometric Distribution have to be
changed (from 2/5) for the expected annual sum to be 750? [4 marks]
6 Probability
(a) Give a brief account of the Trinomial Distribution and include in your
explanation an expression that is equivalent to n
!
r!(n
r)! prqnr for the Binomial
Distribution. [5 marks]
(b) An indicator light can be in one of three states: OFF, FLASHING and ON, with
probabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lights
whose states are mutually independent.
(i) What is the probability that all fifive lights are OFF? [3 marks]
(ii) What is the probability that three lights are OFF, one light is FLASHING
and one light is ON? [3 marks]
(iii) What is the probability that three or more lights are OFF and at most one
is ON? [9 marks]
All results must be expressed as fractions.
Consider an operating system that uses hardware support for paging to provide virtual memory to applications. (a) (i) Explain how the hardware and operating system support for paging combine to prevent one process from accessing another's memory. [3 marks] (ii) Explain how space and time overheads arise from use of paging, and how the Translation Lookaside Buffer (TLB) mitigates the time overheads. [3 marks] (b) Consider a system with a five level page table where each level in the page table is indexed by 9 bits and pages are 4 kB in size. A TLB is provided that is indexed by the first 57 bits of the address provided by the process, and achieves a 90% hit rate. A main memory access takes 40 ns while an access to the TLB takes 10 ns. The maximum memory read bandwidth is 100 GB/s. (i) What is the effective memory access latency? [4 marks] (ii) A colleague suggests replacing the system above with one that provides 80 GB/s memory read bandwidth and main memory access latency of 30 ns. Explain whether you should accept the replacement or not, and why. [4 marks] (c) A creative engineer suggests structuring the TLB so that not all the bits of the presented address need match to result in a hit. Suggest how this might be achieved, and what might be the costs and benefits of doing so. [6 marks]
(a) Describe two quantitative and two qualitative techniques for analysing the usability of a software product. [4 marks] (b) Compare the costs and benefits of the quantitative techniques. [6 marks] (c) Compare the costs and benefits of the qualitative techniques. [6 marks] (d) If restricted to a single one of these techniques when designing a new online banking system, which would you choose and why?
(a) Suppose that women who live beyond the age of 80 outnumber men in the same age group by three to one. How much information, in bits, is gained by learning that a person who lives beyond 80 is male? [2 marks] (b) Consider n discrete random variables, named X1, X2, . . . , Xn, of which Xi has entropy H(Xi), the largest being H(XL). What is the upper bound on the joint entropy H(X1, X2, . . . , Xn) of all these random variables, and under what condition will this upper bound be reached? What is the lower bound on the joint entropy H(X1, X2, . . . , Xn)? [3 marks] (c) If discrete symbols from an alphabet S having entropy H(S) are encoded into blocks of length n symbols, we derive a new alphabet of symbol blocks S n . If the occurrence of symbols is independent, then what is the entropy H(S n ) of this new alphabet of symbol blocks? [2 marks] (d) Consider an asymmetric communication channel whose input source is the binary alphabet X = {0, 1} with probabilities {0.5, 0.5} and whose outputs Y are also this binary alphabet {0, 1}, but with asymmetric error probabilities. Thus an input 0 is flipped with probability , but an input 1 is flipped with probability , giving this channel matrix p (i) Give the probabilities of both outputs, p(Y = 0) and p(Y = 1). [2 marks] (ii) Give all the values of (, ) that would maximise the capacity of this channel, and state what that capacity then would be. [3 marks] (iii) Give all the values of (, ) that would minimise the capacity of this channel, and state what that capacity then would be. [3 marks] (e) In order for a variable length code having N codewords with bit lengths {n1, n2, n3, , nN } to satisfy the prefix property, what condition must be satisfied? (Express the condition, but do not try to prove it.) [1 mark] (f ) The information in continuous signals which are strictly bandlimited (lowpass or bandpass) is quantised, in that such continuous signals can be completely represented by a finite set of discrete samples. Describe two theorems about how discrete samples suffice for exact reconstruction of continuous bandlimited signals, even at all the points between the sampled values. [4 mark
(a) A two state Markov process emits the letters {A, B, C, D, E} with the probabilities shown for each state. Changes of state can occur when some of the symbols are generated, as indicated by the arrows. 4.2 Information sources with memory We will wish to consider sources with memory, so we also consider Markov processes. Our four event process (a symbol is generated on each edge) is shown graphically together with a two state Markov process for the alphabet fA, B, C, D, Eg in gure 17. We can then solve for the state occupancy using ow equations (this example is trivial).
ess with states fS 1; S2; : : :Sng, with transition probabilities pi(j) being the probability of moving from state Si to state Sj (with the emission of some symbol). First we can dene the entropy of each state in the normal manner: Hi = X j pi(j) log2 pi(j) and then the entropy of the system to be the sum of these individual state entropy values weighted with the state occupancy (calculated from the ow equations):
Pipi(j) log pi(j) (45) Clearly for a single state, we have the entropy of the memoryless source. 4.3 The Source Coding theorem Often we wish to eciently represent the symbols generated by some source. We shall consider encoding the symbols as binary digits. 19 (i) What are the state occupancy probabilities? [1 mark] (ii) What is the probability of the letter string AD being emitted? [1 mark] (iii) What is the entropy of State 1, what is the entropy of State 2, and what is the overall entropy of this symbol generating process? [5 marks] (b) A fair coin is secretly flipped until the first head occurs. Let X denote the number of flips required. The flipper will truthfully answer any "yes-no" questions about his experiment, and we wish to discover thereby the value of X as efficiently as possible. (i) What is the most efficient possible sequence of such questions? Justify your answer. [2 marks] (ii) On average, how many questions should we need to ask? Justify your answer. [2 marks] (iii) Relate the sequence of questions to the bits in a uniquely decodable prefix code for X. [1 mark] (c) Define complex Gabor wavelets, restricting yourself to one-dimensional functions if you wish, and list four key properties that make such wavelets useful for encoding and compressing information, as well as for pattern recognition. Explain how their self-Fourier property and their closure under multiplication (i.e. the product of any two of them is yet again a Gabor wavelet) gives them also closure under convolution. Mention one disadvantage of such wavelets for reconstructing data from their projection coefficients. [8 mark
(a) Consider an alphabet of 5 symbols whose probabilities are as follows: A B C D E 1 16 1 4 1 8 1 16 1 2 One of these symbols has been selected at random and you need to discover which symbol it is by asking 'yes/no' questions that will be truthfully answered. (i) What would be the most efficient sequence of such questions that you could ask in order to discover the selected symbol? [2 marks] (ii) By what principle can you claim that each of your proposed questions in the sequence is maximally informative? [2 marks] (iii) On average, how many such questions will need to be asked before the symbol is discovered? What is the entropy of the symbol set? [2 marks] (iv) Construct a uniquely decodable prefix code for the symbols. Explain why it is uniquely decodable and why it has the prefix property. [2 marks] (v) Relate the bits in the code words forming your prefix code to the 'yes/no' questions that you proposed in (i). [2 marks] (b) Explain how the bits in an IrisCode are set by phase sequencing. Discuss how quantisation of the complex plane into phase quadrants sets each pair of bits; why it is beneficial for quadrant codes to form a Gray Code; how much entropy is thereby typically extracted from iris images; and why such bit sequences enable extremely efficient identity searches and matching. [5 marks] (c) Consider a noisy analog communication channel of bandwidth = 1 MHz, which is perturbed by additive white Gaussian noise whose total spectral power is N0 = 1. Continuous signals are transmitted across such a channel, with average transmitted power P = 1,000. Give a numerical estimate for the channel capacity, in bits per second, of this noisy channel. Then, for a channel having the same bandwidth but whose signal-to-noise ratio P N0 is four times better, repeat your numerical estimate of capacity in bits per second. [5 marks]
Continuous Mathematics
The complex form of the Fourier series is:
f(x) =
+
X
k=
ckei2kx
where ck is a complex number and ck = ck.
(a) Prove that the complex coeffiffifficient, ck, encodes the amplitude and phase
coeffiffifficients, Ak and k, in the alternative form:
f(x) =
+
X
k
=0
Ak cos(2kx k)
[10 marks]
(b) What is special about the case k = 0? [2 marks]
(c) Explain how the coeffiffifficients, ck, of the Fourier series of the periodic function,
f(x):
f(x) = f(x + T), x
can be obtained from the Fourier transform, FL(), of the related function,
fL(x):
fL(x) = f(x
),
T
2 6 x < T
2
0
,
otherwise
[8 marks]
2 Concurrent Systems
An interprocess communication environment is based on synchronous message
passing. A server is to be designed to support a moderate number of simultaneous
client requests.
Clients send a request message to the server, continue in parallel with server
operation, then wait for the server's reply message.
Discuss the design of the server's interaction with the clients. Include any problems
you foresee and discuss alternative solutions to them. [20 marks]
2CST.2001.4.3
3 Further Java
(a) Describe how mutual-exclusion locks provided by the synchronized keyword
can be used to control access to shared data structures. In particular you
should be clear about the behaviour of concurrent invocations of difffferent
synchronized methods on the same object, or of the same synchronized method
on difffferent objects. [6 marks]
(b) Consider the following class defifinition:
class Example implements Runnable {
public static Object o = new Object();
int count = 0;
public void run() {
while (true) {
synchronized (o) {
count ++;
}
}
}
}
Show how to start two threads, each executing this run method. [2 marks]
(c) When this program is executed, only one of the count fifields is found to
increment, even though threads are scheduled preemptively. Why might this
be? [2 marks]
(d) Defifine a new class FairLock. Each instance should support two methods, lock
and unlock, which acquire and release a mutual exclusion lock such that calls
to unlock never block the caller, but will allow the longest-waiting blocked
thread to acquire the lock. The lock should be recursive, meaning that the
thread holding the lock may make multiple calls to lock without blocking.
The lock is released only when a matched number of unlock operations have
been made.
You may wish to make use of the fact the Thread.currentThread() returns
the instance of Thread that is currently executing. [10 marks]
3
[TURN OVERCST.2001.4.4
4 Compiler Construction
Consider the following grammar giving the concrete syntax of a language:
E id
C E = E;
C {B}
C C repeatwhile E
C if E then C
C if E then C else C
B B C
B C
S C eof
where C repeatwhile E has the same meaning as do C while E in C or Java.
(a) List the terminals and non-terminals of this grammar and explain the
signifificance of S. [3 marks]
(b) Identify any ambiguities in the above grammar and rewrite it to remove them,
ensuring that your new grammar generates exactly the same set of strings.
[4 marks]
(c) Specify a suitable abstract syntax, for example by giving a type declaration
in a programming language of your choice, which might be used to hold parse
trees for this language. [3 marks]
(d) Give either a recursive descent parser or a characteristic fifinite state machine
(e.g. for SLR(1)) with associated parser for your grammar. Your parser need
not return a parse treeit suffiffiffices for your parser either to accept or to reject
the input string. [10 marks]
4CST.2001.4.5
5 Data Structures and Algorithms
(a) Outline how you would determine whether the next line segment turns left or
right during the Graham scan phase of the standard method of computing the
convex hull of a set of points in a plane. [5 marks]
(b) Describe in detail an effiffifficient algorithm to determine how often the substring
ABRACADABRA occurs in a vector of 106 characters. Your algorithm should be
as effiffifficient as possible. [10 marks]
(c) Roughly estimate how many character comparisons would be made when your
algorithm for part (b) is applied to a vector containing 106 characters uniformly
distributed from the 26 letters A to Z. [5 marks]
6 ECAD
(a) When designing clocked circuits there are times when asynchronous inputs
have to be sampled which may result in metastable behaviour in state holding
elements. How might metastability be avoided when sampling asynchronous
inputs? [5 marks]
(b) An optical shaft encoder (e.g. used on the internal rollers of a mechanical
mouse) consists of a disk with an evenly spaced alternating transparent and
opaque grating around the circumference. Two optical sensors are positioned
such that when one sensor is at the middle of an opaque region, the other
is at the edge. Consequently, the following Gray code sequence is produced,
depending upon the direction of rotation:
positive rotation
negative rotation
A shaft decoder module is required to convert the Gray code into an 8-bit
position. The 8-bit position should be incremented every time the input
changes from one state to another in a positive direction (e.g. from 00 to
01, or from 10 to 00). Similarly, the 8-bit position should be decremented
every time the input changes from one state to another in a negative direction
(e.g. from 00 to 10, or from 01 to 00).
Write and comment a Verilog module which performs the function of a shaft
decoder. [15 marks]
5
[TURN OVERCST.2001.4.6
7 Operating System Functions
(a) In the context of virtual memory management:
(i) What is demand paging? How is it implemented? [4 marks]
(ii) What is meant by temporal locality of reference? [2 marks]
(iii) How does the assumption of temporal locality of reference inflfluence page
replacement decisions? Illustrate your answer by brieflfly describing an
appropriate page replacement algorithm or algorithms. [3 marks]
(iv) What is meant by spatial locality of reference? [2 marks]
(v) In what ways does the assumption of spatial locality of reference inflfluence
the design of the virtual memory system? [3 marks]
(b) A student suggests that the virtual memory system should really deal with
"objects" or "procedures" rather than with pages. Make arguments both for
and against this suggestion. [4 and 2 marks respectively]
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi