s1 educated (SSE) student for every three public school educated (PSE) students. Reasoning that students are not
Question:
s1 educated (SSE) student for every three public school educated (PSE) students. Reasoning that students are not very dissimilar from threads, he suggests the following entry and exit routines be followed: JCR = new Semaphore( threads */ enterRoom() { enterRoom() { signal(JCR, 3); wait(JCR); } } leaveRoom() { leaveRoom() { wait(JCR); signal(JCR, 1); wait(JCR); } wait(JCR); } We can assume that undergraduates are smart enough not to try and enter the JCR when it is full. Yet despite this, the Master's solution does not work quite as hoped! Describe what can go wrong, and suggest a fix. [4 marks]
Java generics allows an ArrayList object to be constrained to use a single specific type (e.g. ArrayList). However, some applications require the ability to store objects of multiple unrelated types. In this question the aim is to store Integer objects alongside LinkedList objects. (a) One solution is to use ArrayList, since all Java objects extend Object. Explain why this is bad practice. [2 marks] (b) Seeking to provide a solution that allows an arbitrary set of constrained types, a programmer writes an abstract ConstrainedArray base class. To use it, the class is extended and a specialised void add(...) method should be provided for each acceptable type. public abstract class ConstrainedArray { protected ArrayList mArray = new ArrayList(); public Object get(int idx) {return mArray.get(idx);} public int size() { return mArray.size(); } } (i) Show how to create class IntListArray that extends this base class and accepts only Integer or LinkedList objects. Where appropriate, objects should be copied on insertion. [4 marks] (ii) Describe a sequence of events that would allow external modification of an object stored within an IntListArray, despite correct copying on insertion. How could this be addressed in IntListArray? [3 marks] (iii) By adding protected void add(Object o) {mArray.add(o);} to the ConstrainedArray class, the mArray field can be made private. Show how this would affect your IntListArray class and discuss the advantages of the change from protected to private. [5 marks] (c) The solutions in parts (a) and (b) both involve a get() method returning an Object reference. (i) Explain why this is bad practice. [1 mark] (ii) Propose an alternative solution for a c
This question deals with stochastic processes {N(t), t 0} where N(t) represents the number of events in the time interval [0, t]. (a) (i) Define a Poisson process {N(t), t 0} of rate > 0. [2 marks] (ii) Show that N(t) Pois(t) for each fixed t > 0. You may use the result that limn(1 x/n) n = e x without proof. [4 marks] (iii) Let X1 be the time of the first event of the Poisson process N(t). Show that X1 Exp(). [2 marks] (iv) Now given that N(t) = 1 derive the distribution of the time of the single event in [0, t]. [4 marks] (b) Suppose that events of a Poisson process of rate are independently selected at random with probability p > 0. Show that the process of selected events is also a Poisson process and establish its rate. [2 marks] (c) Describe how your result from part (b) can be used to simulate a nonhomogeneous Poisson process whose rate function (t) is such that (t) for all t 0. [6 marks]
The standard linear regression model uses a hypothesis
(a) Derive a gradient descent algorithm for training the linear regression model
described. [5 marks]
(b) In the application of interest, you believe that it is desirable to train such that
the learned parameters have ||w|| ' 1. Suggest a modifification to E(w, b) that
facilitates this, and derive the corresponding gradient descent training algorithm.
[5 marks]
(c) Describe the components of a general heuristic search problem. [4 marks]
(d) You are faced with a heuristic search problem, but the heuristics you have so far
developed are less effffective than desired. Suggest two ways in which supervised
machine learning might be used to develop a better heuristic, mentioning if
necessary any corresponding disadvantages of using the approach. You may
assume that a collection of problems to be solved by the heuristic search is
available. [6 marks]
2CST1.2021.6.3
2
Artifificial Intelligence
A Boolean satisfifiability problem has four variables, x1, x2, x3 and x4. A literal l
can be a variable or its negation, denoted l. The formula of interest, in conjunctive
normal form (CNF), is
(1)
The aim is to fifind assignments to the variables such that f is true under the usual rules
for Boolean operations. This question addresses the use of more general constraint
satisfaction to solve this problem.
(a) Give a general description of a constraint satisfaction problem (CSP).
[3 marks]
(b) Explain how a Boolean satisfifiability problem in CNF form and with n variables
can be converted to a CSP, also having n variables and having a suitable
constraint for each clause. Illustrate your answer using the 4-variable formula f
in (1). [3 marks]
(c) Explain, again using a constraint corresponding to a clause from (1), how general
constraints can be converted to binary constraints. Provide a graph illustrating
the problem from (1) after it has been converted to a CSP with only binary
constraints. [4 marks]
(d) Explain, how forward checking works in the context of a general CSP. How does
this benefifit a CSP solver? [3 marks]
(e) Using the CSP equivalent you developed for (1), with only binary constraints,
demonstrate how forward checking works using the sequence of assignments
x1 = F, x2 = F, x4 = T. [5 marks]
(f ) How would you expect the solution obtained when applying forward checking to
be affffected if constraints were allowed to propagate more widely? [2 marks]
3CST1.2021.6.4
3
Complexity Theory
(a) Defifine the set of Boolean expressions 2CNF and the language 2SAT over them.
[2 marks]
(b) For a Boolean expression in 2CNF, let G() be the directed graph with vertices
the variables of and their negation, and with edges (a, b) if, and only if, there
is a clause (a b) or (b a) in . Note that an edge (a, b) is in G() if, and
only if, so is the edge (b, a).
Prove that a Boolean expression in 2CNF is unsatisfifiable if, and only if, there
is a variable x in such that there are paths from x to x and from x to x in
G(). [Hint: Recall that the proposition (P Q) is equivalently the implication
(P Q).] [12 marks]
(c) Argue as to whether or not 2SAT is in NL, in P, and in NP. Your answer may
use the fact that NL is closed under complementation. [6 marks]
4CST1.2021.6.5
4
Complexity Theory
(a) For a complexity class C, let co-C = { L | L C } and say that C is closed under
complementation whenever C = co-C.
Argue as to whether the following statements are true, false, or unknown.
(i) All deterministic time complexity classes are closed under complementation.
[3 marks]
(ii) All non-deterministic time complexity classes are closed under
complementation. [3 marks]
(b) For a mapping f : on an alphabet and a language L , defifine
f[L] = { f\ (w) | w L } where f\ (a1 an) = f(a1) f(an).
Prove that L NP implies f[L] NP. [4 marks]
(c) Consider the following decision problem.
Q: Given natural numbers m and n in N, and bits a
(k)
i,j
and bk in
{0, 1} for 1 k m and 1 i, j n, determine whether the system
of equations P 1i,jn a
(k)
i,j
xi xj = bk (1 k m) with unknowns
x1, . . . , xn has a solution in arithmetic modulo 2.
(i) Prove that Q is in NP. [3 marks]
(ii) By means of a polynomial-time reduction from the problem 3CNF, or
otherwise, prove that Q is NP-hard. [Hint: Note, for instance, that x = y
in the Boolean algebra {0, 1} if, and only if, xx + yy = 1 in arithmetic
modulo 2.] [7 marks]
You may use standard results provided that you state them clearly.
5CST1.2021.6.6
5
Computation Theory
(a) For each n, e N, let
(n)
e
denote the partial function Nn* N computed by the
register machine with index e using registers R1, . . . , Rn to store the n arguments
and register R0 to store the result, if any.
Explain why for each m, n N there is a totally defifined register machine
computable function Sm,n : N 1+m N with the property that for all (e, ~x)
N 1+m and ~y Nn
(n
)
S
m,n
(e,~x)(~y)
(m+n)
e
(~x, ~y) (1)
where denotes Kleene equivalence: for all z N, the left-hand side is defifined
and equal to z if and only if the right-hand side is defifined and equal to z.
Your explanation should make clear what assumptions you are making about
the relationship between numbers and register machine programs. [10 marks]
(b) Let f : N 1+m+n* N be a register machine computable partial function of 1+m+n
arguments for some m, n N.
(i) Why is the partial function f : N 1+m+n* N satisfying for all (z, ~x, ~y)
N 1+m+n
f(z, ~x, ~y) f(S1+m,n(z, z, ~x), ~x, ~y) (2)
register machine computable? [3 marks]
(ii) By considering S1+m,n(e, e, ~x) where e is an index for the partial function
f in part (b)(i), prove that there is a totally-defifined register machine
computable function fifix f : Nm N with the property that for all ~x Nm
and ~y Nn
(n)
fifix
f(~x)(~y) f(fifix f(~x), ~x, ~y) (3)
[7 marks]
6CST1.2021.6.7
6
Computation Theory
A set A equipped with a binary operation @ : A A A is a combinatory algebra
if there are elements K, S A satisfying for all a, b, c A
@(@(K, a), b) = a
(1)
@(@(@(S, a), b), c) = @(@(a, c), @(b, c)) (2)
(a) Show that there is a binary operation on the set of equivalence classes of closed
-terms for the equivalence relation of -conversion that makes it a combinatory
algebra. [5 marks]
(b) Show that every combinatory algebra A contains an element I satisfying
@(I, a) = a
(3)
for all a A. [Hint: what does (2) tell us when a = b = K?] [2 marks]
(c) For an arbitrary combinatory algebra A, let A[x] denote the set of expressions
given by the grammar
e ::= x | p aq | (ee)
where x is some fifixed symbol not in A and a ranges over the elements of A.
Given e A[x] and a A, let e[x := a] denote the element of A resulting from
interpreting occurrences of x in e by a, interpreting the expressions of the form
p a0 q by a0 and interpreting expressions of the form (ee0 ) using @.
(i) Give the clauses in a defifinition of e[x := a] by recursion on the structure of
e. [2 marks]
(ii) For each e A[x] show how to defifine an element xe A with the property
that
@(xe, a) = e[x := a] (7)
for all a A. [6 marks]
(d) Recall the usual encoding of Booleans in -calculus. Using Part (c)(ii), show
that in any combinatory algebra A there are elements True, False A and a
function If : A A A satisfying
@(If (a, b), True) = a
(11)
@(If (a, b), False) = b
(12)
for all a, b A
[5 marks]
7CST1.2021.6.8
7
Data Science
(a) Let xt be the number of new COVID infections on date t. We anticipate
approximately exponential growth or decay, xt+1 (1 + )xt , and we would
like to estimate from a dataset (x1, . . . , xT ).
(i) Find the maximum likelihood estimator for for the model
Xt+1 Poisson
You have available a 20 Gbyte disc on which you need to hold an indexed sequential
fifile consisting of variable length records each having a 20 byte key. Records,
including the key, are typically 500 bytes long but never exceed 1000 bytes. The
total size of all the records is never more than 10 Gbytes.
(a) Suggest, in detail, how you would represent this fifile on the disc. You should
choose an organisation that allows
(i) effiffifficient insertion of new records,
(ii) effiffifficient updating of existing records identifified by key, and
(iii) effiffifficient inspection of all records in key order.
[14 marks]
(b) If the total size of the database is 10 Gbytes, estimate, for your organisation
of the fifile, how many disc transfers would be needed to access a record with
a given key, and estimate how many transfers would be required to read the
entire database in sequential order. [6 marks]
2 Computer Design
Modern dynamic random access memories (e.g. DRAM, SDRAM and RAMBUS)
all support burst mode read and write access.
(a) Give an outline of the bus activity for a burst mode read access. [4 marks]
(b) Explain the difffference between a direct mapped cache and an associative cache.
[4 marks]
(c) What cache line replacement policies are typically used for a direct mapped
cache and a set associative cache? [4 marks]
(d) Why are caches able to exploit burst mode accesses, and why is a write buffffer
often used? [4 marks]
(e) What is bus snooping and what does it achieve? [4 marks]
2CST.2002.5.3
3 Digital Communication I
Consider the real-time transport of audio across a network.
(a) What are the advantages of digitising the audio? [5 marks]
(b) What are the disadvantages and how can they be mitigated? [5 marks]
(c) What characteristics of the end-to-end channel across the network would be
desirable, and how are these difffferent from those which would be desirable for
time-insensitive data? [5 marks]
(d) Discuss the applicability of asynchronous and synchronous multiplexing in
carrying real-time audio traffiffiffic. [5 marks]
3
[TURN OVERCST.2002.5.4
4 Concurrent Systems and Applications
(a) The suspend() and resume() methods defifined on java.lang.Thread can be
used to block and unblock a designated thread. Explain why these methods
should not be used. [4 marks]
(b) Defifine a Java class Barrier that pairs together two difffferent kinds of thread
(A and B) in a concurrent system. It should support two methods,
enterA(Object o) and enterB(Object o). A call to one enter method
blocks until a call is made to the other. At that point both invocations
continue, enterA returning the value passed to enterB and vice versa.
[8 marks]
(c) A number of barbers and customers have to co-ordinate their actions in a
barbers' shop. Each barber has a chair in which a customer sits while receiving
a haircut and in which that barber dozes when he has no customer. There is
plenty of waiting space.
Defifine Java classes Barber, Customer and Shop to model this situation. The
class Customer should support two methods:
(i) Barber getHaircut(Shop s) - request service at s, blocking until the
customer is served and returning the allocated barber;
(ii) void leaveChair(Barber b) - signal that b can take another customer.
The class Barber should support two corresponding methods:
(i) Customer getCustomer(Shop s) - wait to be allocated a customer at s;
(ii) void finishedCustomer(Customer c) - signal to c that the haircut is
fifinished and wait for c to leave the chair.
[8 marks]
4CST.2002.5.5
SECTION B
5 Comparative Programming Languages
This question concerns the representation of parse tree nodes for expressions
composed of integer constants, identififiers, and integer operators for addition,
subtraction, multiplication and division. In a typeless language, such as BCPL,
each node can be implemented as a vector whose fifirst element holds an integer
identifying the node operator. The size of the vector and the kinds of value held in
the other elements then depends on this node operator.
(a) Complete the description of how you would represent such integer expressions
in a typeless language. [5 marks]
(b) Suggest how you would represent such integer expressions in C and either ML
or Java. [10 marks]
(c) Brieflfly discuss the relative merits of your C data structure compared with that
used in the typeless approach. [5 marks]
6 Compiler Construction
(a) Assuming a Java type is given to each variable, state a method by which an
overloaded operator (such as +,- etc.) in a Java program can be determined
to be an int, real or other operator. [3 marks]
(b) Explain, using pseudo-code as appropriate, how to convert a syntax-tree into
stack code such as that used in the JVM. For the purposes of this question, you
only need consider trees representing bodies of void-returning functions, and
these bodies only as consisting of a list of statements of the form int x = e;
or x = e; where x ranges over variables and e over expressions; expressions
contain variables, integer constants, the binary operator + and static method
invocations. [10 marks]
(c) Show how a sequence of simple stack code instructions, such as those used
in your answer to part (b) above, can be translated into a sequence of
instructions for a register-oriented architecture of your choice, for example
ARM or Pentium. [7 marks]
5
[TURN OVERCST.2002.5.6
7 Prolog for Artifificial Intelligence
(a) Give a simple defifinition of the Prolog predicate dfx that can perform symbolic
difffferentiation with respect to the variable x of expressions composed of
integers (e.g. 0, 1, . . .), symbolic constants (e.g. a, b, . . .), symbolic variables
(e.g. x, y, . . .) and the operators +, - and *, for addition, subtraction and
multiplication. The fifirst argument of dfx is the expression to difffferentiate
and the second argument is the result. Your defifinition need not perform any
simplifification of the result. [6 marks]
(b) Trace the execution of the call: dfx(x*x-2, R). [2 marks]
(c) Now modify your defifinition so that it simplififies the result by the applications
of rewriting rules such as: 1*xx and x-0x. [8 marks]
(d) Discuss to what extent, if any, either of your predicates could be used to
integrate an expression. [4 marks]
8 Databases
(a) Describe the relational model of data. [6 marks]
(b) Explain the following concepts in relational databases:
(i) entity integrity constraint; [1 mark]
(ii) foreign key and how it can specify a referential integrity constraint
between two relations; [4 marks]
(iii) semantic integrity constraint. [1 mark]
(c) (i) What is a functional dependency? [1 mark]
(ii) Defifine Boyce-Codd Normal Form (BCNF). [3 marks]
(iii) Defifine Third Normal Form (3NF). [3 marks]
(iv) What is the relationship between BCNF and 3NF? [1 mark]
6CST.2002.5.7
SECTION C
9 Semantics of Programming Languages
(a) The integer expressions
e
of a C-like language take the form
e ::= n | x | x++ | ++x | e + e, where n ranges over integer constants and
x over integer storage variables. The expression x++ returns the value stored
in the integer variable x and then increments the stored value by one; whereas
++x fifirst increments the stored value by one and then returns it. Assuming
a left-to-right evaluation order, give an operational semantics for all these
expressions, in the form of an evaluation relation h s, ei hs0 , ni , where s, s0
range over states which are fifinite functions from integer storage variables to
integers. [5 marks]
(b) The commands (statements) c of this same language take the form
c ::= x = e | x += e | c;c. The fifirst form is assignment and the last is
sequencing; the command x += e evaluates e, adds the result to the value
stored in x and stores the result there. Give an operational semantics for these
commands in the form of an evaluation relation h s, ci s0 (where s, s0 are as
above). [4 marks]
(c) Defifine the notion of semantic equivalence for these expressions and commands.
[3 marks]
(d) For each of the following pairs of expressions or commands, state, with
justifification, whether or not they are semantically equivalent.
(i) ++x and x++ + 1
[2 marks]
(ii) x = ++x and x = x++
[2 marks]
(iii) x = ++x and x += 1
[2 marks]
(iv) x += e and x = x + e, for any e
[2 marks]
7
[TURN OVERCST.2002.5.8
10 Foundations of Functional Programming
(a) Explain how a lambda-term can be converted into a form that uses only the
combinators S and K. [4 marks]
(b) Illustrate your method by writing down a lambda term for each of the following
functions and then expressing it in terms of just S and K.
(i) fun I x = x
(ii) fun B f g x = f (g x)
(iii) fun C f x y = f y x
(iv) fun A x y = y (x x y)
[4 marks each]
11 Logic and Proof
(a) For each of the following formulae, state (with justifification) whether it is
satisfifiable, valid or neither:
((Q R) Q) Q
[2 marks]
((P Q) P) Q
[2 marks]
xy [P(x, y) xy P(x, y)] [3 marks]
[x (P(x) Q(x)) x P(x)] x Q(x) [3 marks]
(b) Brieflfly outline the semantics of fifirst-order logic, taking as an example the
formula xy f(x, y) = f(y, x). [6 marks]
(c) Exhibit a model that satisfifies both of the following formulae (a is a constant):
x g(x)
6
=
a
xy [g(x) = g(y) x = y]
[4 marks]
8CST.2002.5.9
12 Complexity Theory
(a) Give a precise defifinition of what is meant by the statement that a decision
problem A is polynomial-time reducible to a decision problem B. [2 marks]
(b) Consider the following three decision problems on graphs.
Connectthe collection of graphs G such that there is a path between
any two vertices of G.
Hamiltonthe collection of graphs that contain a Hamiltonian cycle.
non-3-colourthe collection of graphs that are not 3-colourable.
For each of the following statements, state whether it is true, false or an
unresolved open question. Give a brief justifification for your answer.
(i) Connect is decidable by a polynomial time algorithm.
(ii) Hamilton is decidable by a polynomial time algorithm.
(iii) non-3-colour is decidable by a polynomial time algorithm.
(iv) Connect is polynomial-time reducible to Hamilton.
(v) Hamilton is polynomial-time reducible to non-3-colour.
(vi) non-3-colour is polynomial-time reducible to Connect.
[3 marks each]
a. If the next incoming authenticated packet has sequence number 340, what will the receiver do with the packet, and what will be the parameters of the window after that? b. If instead the next incoming authenticated packet has sequence number 598, what will the receiver do with the packet, and what will be the parameters of the window after that? c. If instead the next incoming authenticated packet has sequence number 110, what will the receiver do with the packet, and what will be the parameters of the window after that? 20.6 When tunnel mode is used, a new outer IP header is constructed. For both IPv4 and IPv6, indicate the relationship of each outer IP header field and each extension header in the outer packet to the corresponding field or extension header of the inner IP packet. That is, indicate which outer values are derived from inner values and which are constructed independently of the inner values. 20.7 End-to-end authentication and encryption are desired between two hosts. Draw figures similar to Figure 20.8 that show each of the following. a. Transport adjacency with encryption applied before authentication. b. A transport SA bundled inside a tunnel SA with encryption applied before authentication. c. A transport SA bundled inside a tunnel SA with authentication applied before encryption.
Prior to the introduction of IEEE 802.11i, the security scheme for IEEE 802.11 was Wired Equivalent Privacy (WEP). WEP assumed all devices in the network share a secret key. The purpose of the authentication scenario is for the STA to prove that it possesses the secret key. Authentication proceeds as shown in Figure 18.12. The STA sends a message to the AP requesting authentication. The AP issues a challenge, which is a sequence of 128 random bytes sent as plaintext. The STA encrypts the challenge with the shared key and returns it to the AP. The AP decrypts the incoming value and compares it to the challenge that it sent. If there is a match, the AP confirms that authentication has succeeded. a. What are the benefits of this authentication scheme? b. This authentication scheme is incomplete. What is missing and why is this important? Hint: The addition of one or two messages would fix the problem. c. What is a cryptographic weakness of this scheme? 18.5 / KEY TERMS, REVIEW QUESTIONS, AND PROBLEMS 611 18.3 For WEP, data integrity and data confidentiality are achieved using the RC4 stream encryption algorithm. The transmitter of an MPDU performs the following steps, referred to as encapsulation: 1. The transmitter selects an initial vector (IV) value. 2. The IV value is concatenated with the WEP key shared by transmitter and receiver to form the seed, or key input, to RC4. 3. A 32-bit cyclic redundancy check (CRC) is computed over all the bits of the MAC data field and appended to the data field. The CRC is a common error-detection code used in data link control protocols. In this case, the CRC serves as a integrity check value (ICV).
The 1988 model of X.509 lists properties that RSA keys ought to satisfy to be cozy given present day information approximately the difficulty of factoring large numbers. The discussion concludes with a constraint on the general public exponent and the modulus n: It ought to be ensured that e 7 log2(n) to prevent attack by using taking the eth root mod n to reveal the plaintext. Although the constraint is accurate, the motive given for requiring it is inaccurate. What is inaccurate with the motive given and what's the ideal purpose? 14.Four Find at least one intermediate certification authority's certificate and one trusted root certification authority's certificate for your pc (e.G., inside the browser). Print screenshots of each the overall and details tab for every certificate. 14.5 NIST defines the term cryptoperiod as the time span throughout which a selected secret's legal to be used or wherein the keys for a given gadget or application can also remain in impact. One file on key management makes use of the following time diagram for a shared mystery key. Originator usage duration Recipient usage duration Cryptoperiod
Explain the overlap by using giving an example software in which the originator's usage period for the shared secret key starts offevolved earlier than the recipient's utilization length and also ends before the recipients utilization length. 14.6 Consider the subsequent protocol, designed to allow A and B determine on a fresh, shared consultation key KAB = . We expect that they already percentage an extended-term key KAB. 1. A S B: A, NA. 2. B S A: E(KAB, [NA, KAB = ]) three. A S B: E(KAB = , NA) a. We first try to recognize the protocol dressmaker's reasoning: Why would A and B consider after the protocol ran that they share KAB = with the different celebration? Why might they consider that this shared secret's sparkling? In both instances, you ought to give an explanation for each the motives of each A and B, so your solution should entire the sentences A believes that she shares KAB = with B due to the fact that . . . B believes that he shares KAB = with A considering the fact that . . . A believes that KAB = is fresh in view that . . . B believes that KAB = is sparkling because . . . B. Assume now that A starts a run of this protocol with B. However, the relationship is intercepted through the adversary C. Show how C can start a new run of the protocol the usage of mirrored image, inflicting A to believe that she has agreed on a fresh key with B (in spite of the fact that she has only been speaking with C). Thus, specially, the notion in (a) is false. C. Propose a amendment of the protocol that forestalls this attack. 14.7 What are the control features of a... [7:16 PM, 3/24/2022] .: In SSL and TLS, why is there a separate Change Cipher Spec Protocol in place of which include a change_cipher_spec message in the Handshake Protocol? 17.2 What cause does the MAC serve for the duration of the change cipher spec TLS exchange? 17.3 Consider the subsequent threats to Web protection and describe how every is countered by way of a selected function of TLS.