COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6...

13
CST2.2017.7.1 COMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet. On each cover sheet, write the numbers of all attempted questions, and circle the number of the question attached. You may not start to read the questions printed on the subsequent pages of this question paper until instructed that you may do so by the Invigilator STATIONERY REQUIREMENTS Script paper Blue cover sheets Tags SPECIAL REQUIREMENTS Approved calculator permitted

Transcript of COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6...

Page 1: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.1

COMPUTER SCIENCE TRIPOS Part II

Tuesday 6 June 2017 1.30 to 4.30

COMPUTER SCIENCE Paper 7

Answer five questions.

Submit the answers in five separate bundles, each with its own cover sheet. On eachcover sheet, write the numbers of all attempted questions, and circle the number ofthe question attached.

You may not start to read the questionsprinted on the subsequent pages of thisquestion paper until instructed that you

may do so by the Invigilator

STATIONERY REQUIREMENTSScript paperBlue cover sheetsTags

SPECIAL REQUIREMENTSApproved calculator permitted

Page 2: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.2

1 Advanced Algorithms

(a) Into what three cases can a linear program in standard form be classified?[3 marks]

(b) Consider the (unweighted) vertex cover problem for the graph G = (V,E) withV = {1, 2, 3} and E = {{1, 2}, {2, 3}, {1, 3}}.

(i) Write down the linear program relaxation for the vertex cover problem andsolve the linear program. [6 marks]

(ii) Based on the solution of the linear program in (b)(i), derive an integersolution using the rounding approach described in the lecture. [2 marks]

(c) Consider the following randomised algorithm for the unweighted vertex coverproblem:

Initialize S to be the empty set

For all edges e=(u,v) do

If neither u nor v belongs to S

Randomly choose u or v with probability 1/2

and add the vertex to S

End If

End For

Return S

Derive an upper bound, as tight as possible, on the approximation ratio of thealgorithm.

Hint: Try to find an invariant that bounds from below the size of the intersectionof the current solution S = S(i) with the optimum solution, where S(i) denotesthe set S after the i-th iteration of the FOR loop. [9 marks]

2

Page 3: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.3

2 Advanced Graphics

(a) Briefly explain the global illumination methods radiosity and photon mapping.Highlighting the strengths and weaknesses of each method, compare and contrastthe two.You will be marked for correctness, clarity and brevity. [8 marks]

Recall that the signed distance field (SDF) expression of a surface returns thesigned nearest distance from a sample point to the surface. This is well-suited toray-marching on a GPU. As an example, the SDF method describing a unit cubecentred at the origin may be written in openGL shading language (GLSL) as:

float cube(vec3 pt) {

return max(abs(pt.x), max(abs(pt.y), abs(pt.z))) - 1;

}

(b) Give an SDF method cylY(pt, len, radius) for a finite cylinder of specifiedlength and radius, centred at the origin, parallel to the Y axis. [4 marks]

(c) Give an SDF method hollowedSphere(pt) which specifies the model shown inFigure 1: a unit sphere hollowed along each axis by a cylindrical hole of radius0.5. [6 marks]

(d) How would you repeat your hollowed sphere at two-unit intervals infinitely acrossthe XZ plane as illustrated in Figure 2? [2 marks]

Figure 1: A unit sphere hollowed alongeach axis by a hole of radius 0.5

Figure 2: The hollowed unit sphereinfinitely repeated in XZ at intervalsof 2

Ground plane is for illustration only

3 (TURN OVER)

Page 4: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.4

3 Machine Learning and Bayesian Inference

(a) For random variables (RVs) A1, A2 and B, define what it means for A1 to beconditionally independent of A2 given B, written A1 ⊥ A2|B. [1 mark]

(b) Given mutually disjoint sets X1, X2 and Y of random variables from someBayesian network, define what it means to say that a path from x1 ∈ X1 tox2 ∈ X2 is blocked by Y . [5 marks]

(c) Given mutually disjoint sets X1, X2 and Y of random variables from someBayesian network, define what it means for X1 and X2 to be d-separated by Y .What does this tell you about the probability distribution represented by theBayesian network? [3 marks]

(d) Consider the following Bayesian network.

A B

C D

E

F

G

In each of the following cases, establish whether or not X1 ⊥ X2|Y :

(i) X1 = {A,E}, X2 = {G} and Y = {F}. [2 marks]

(ii) X1 = {A}, X2 = {D} and Y = {G}. [3 marks]

In each case explain your answer.

(e) Define how Bayesian networks and Markov random fields are used to representprobability distributions, and briefly describe the trade-offs involved in choosingone versus the other. [6 marks]

4

Page 5: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.5

4 Bioinformatics

(a) Discuss the time and space complexity of dynamic programming algorithms inthe context of sequence alignment problems. [6 marks]

(b) Describe the differences between Soft and Hard Clustering. [6 marks]

(c) Construct the de Bruijn graph of TACCTTCAGCGCCTTC by splitting it into k-mersfor a suitable value of k. Comment on how the choice of k affects theconstruction. Discuss the use of de Bruijn graphs in the context of genomesequencing. [8 marks]

5 Business Studies

(a) Describe five types of Intellectual Property. [5 marks]

(b) Describe five topics that might be in a Market Requirements Document.[5 marks]

(c) Giles Murchiston, a PhD student, has invented a new algorithm to control adog walking robot. He realises that his algorithm may have wider applicationsincluding driverless cars, factory and farm robots, drones, and uses such asdomestic robot lawnmowers or robot vacuum cleaners. Advise Giles on theexploitation of his idea. [10 marks]

5 (TURN OVER)

Page 6: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.6

6 Comparative Architectures

(a) What features of a processor’s instruction set are desirable if a pipelinedimplementation is planned? [5 marks]

(b) The performance of a processor typically improves when a modest number ofpipeline stages are created. Why does it become difficult to maintain near linearperformance gains with deeper pipelines? [5 marks]

(c) Clustered superscalar processors partition functional units into clusters. Dataforwarding within a cluster operates as normal allowing dependent instructionsto execute on consecutive clock cycles. Communication between clustersnormally incurs an additional delay of 1 or 2 clock cycles. The clusteringidea may also be extended to include the issue buffer (also known as the issuewindow).

(i) What problem does clustering attempt to solve? [5 marks]

(ii) Assume a processor has two symmetric clusters that contain both functionalunits and an issue buffer. In this processor, instructions must be steeredto a particular cluster before they are inserted in an issue buffer. Whatshould the two basic goals of a good steering policy be? [5 marks]

6

Page 7: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.7

7 Denotational Semantics

(a) (i) Define the notion of least pre-fixed point fix(f) of a continuous endofunctionf on a domain and state Tarski’s fixed point theorem for it. [2 marks]

(ii) State Scott’s fixed point induction principle. [2 marks]

(b) Let f : D → D, g : E → E, and h : D → E be continuous functions betweendomains such that h ◦ f = g ◦ h : D → E. Show that if h is strict (that is,h(⊥D) = ⊥E) then fix(g) = h

(fix(f)

). [4 marks]

(c) Let Σ∗ denote the set of strings over an alphabet Σ, and let P(Σ∗) be the domainof all subsets of Σ∗ ordered by inclusion.

Consider the continuous functions

(union) + : P(Σ∗)× P(Σ∗)→ P(Σ∗)

(concatenation) · : P(Σ∗)× P(Σ∗)→ P(Σ∗)

given, for all X, Y ⊆ Σ∗, by

X + Y = {w ∈ Σ∗ | w ∈ X or w ∈ Y }X · Y = {uv ∈ Σ∗ | u ∈ X and v ∈ Y }

(i) Using part (b), or otherwise, show that, for all A,B,C ⊆ Σ∗,

(1) fix(λX.C ·B + A ·X

)= fix

(λX.C + A ·X

)·B [4 marks]

(2) fix(λX.A · C + A ·B ·X

)= A · fix

(λX.C +B · A ·X

)[4 marks]

(ii) For P ⊆ Σ∗, let P ? ⊆ Σ∗ be defined as

P ? = fix(λX.E + P ·X

)where E denotes the singleton set {ε} consisting of the empty string ε.

Using part (c)(i), or otherwise, show that, for all S, T ⊆ Σ∗,

(S · T )? · S = S · (T · S)? [4 marks]

7 (TURN OVER)

Page 8: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.8

8 Hoare Logic and Model Checking

Consider a programming language that consists of commands C composed fromassignments V := E (where E is an expression) using sequences C1;C2, conditionalsIF S THEN C1 ELSE C2 (where S is a statement) and while-loops WHILE S DO C.

(a) Carefully explain the meaning of total correctness Hoare triples. [2 marks]

(b) Suggest a command C such that the following partial correctness triple holds.

{X = x} C {1 = 2}

Explain why the triple holds. [4 marks]

(c) Consider Hoare triples of the form {P} X := E {P [E/X]} where P , X and E

range over formulas, variables and expressions, respectively. Recall that P [E/X]denotes P with E substituted for every occurrence of X in P .

Write down an instance of such a triple that cannot be proved using Hoare logicand explain why it cannot be proved. [4 marks]

(d) Write down a partial correctness specification for a command that adds theinitial values stored in variables X and Y. The command should store the resultin a variable Z. [4 marks]

(e) Propose a loop invariant for proving the following partial correctness triple.

{X = n ∧ Y = 0 ∧ n ≥ 0}WHILE X > 0 DO (Y := Y + X; X := X - 1)

{Y =n∑

i=1

i}

[6 marks]

8

Page 9: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.9

9 Human–Computer Interaction

This question relates to the design of interactive augmented reality applications.Consider a future application in which a (static) public billboard is augmented sothat people passing in the street can see and modify an enhanced view, for exampleadding and editing caption text or speech bubbles over their personalised view of thebillboard. This augmented functionality will be available either using hand-heldmobile devices such as a touch-screen phone, or head-mounted displays such asMicrosoft Hololens. Whichever type of device is used, users should be able to controlthe application either using hand gestures or gaze control.

(a) Discuss the requirements for sensor configuration and computer vision pro-cessing, to achieve the necessary detection and registration of the augmentedinteraction in each of the four possible combinations of the display and controlmethods described above. [8 marks]

(b) This part relates only to the head-mounted display version of the proposedproduct.

(i) Describe a technical approach that applies Bayes’ theorem to improve theperformance of command gesture recognition. [6 marks]

(ii) Describe a technical approach that applies Bayes’ theorem to improve theperformance of gaze-controlled text entry. [6 marks]

9 (TURN OVER)

Page 10: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.10

10 Information Theory

(a) An error-correcting (7/4) Hamming code combines four data bits b3, b5, b6, b7with three error-correcting bits: b1 = b3 ⊕ b5 ⊕ b7, b2 = b3 ⊕ b6 ⊕ b7, andb4 = b5 ⊕ b6 ⊕ b7. The 7-bit block is then sent through a noisy channel, whichcorrupts one of the seven bits. The following incorrect bit pattern is received:

b1 b2 b3 b4 b5 b6 b7

1 1 0 1 0 0 0

Evaluate three syndromes that are derived upon reception of the 7-bit block:s1 = b1⊕ b3⊕ b5⊕ b7, s2 = b2⊕ b3⊕ b6⊕ b7, s4 = b4⊕ b5⊕ b6⊕ b7, and providethe corrected 7-bit block that was the input to this noisy channel. [5 marks]

(b) Consider a noisy channel that suffers from additive noise which is not uniformin power across frequencies, but where instead the noise power attenuatesexponentially with frequency ω. This channel has a signal-to-noise ratio SNR(ω)that therefore improves at higher frequencies, as: SNR(ω) = 2ω − 1 over thepossible range. Within some interval [ω1, ω2] of the spectrum, with ω2 > ω1 > 0,what is the information capacity C of this noisy channel in bits/sec? [5 marks]

(c) Explain the Lempel-Ziv lossless compression algorithm, including its principle,its steps, its payload requirements, and its adaptive variants. [5 marks]

(d) The following traces show how an IrisCode bit sequence (bottom) is computedfrom a sample of human iris texture (top), for compact pattern encoding whosehigh entropy makes identification very reliable. Explain the roles of Gaborwavelets and of Logan’s Theorem in reference to these traces. [5 marks]

0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360

8010

012

014

0

Real Iris: Angular Signal Sample

Angle

0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360

−30

0−

100

100

300

Angular Gabor Wavelet Convolution

Angle

Encoded Bit Stream in IrisCode

10

Page 11: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.11

11 Natural Language Processing

Compositional semantics is concerned with modelling the meaning of phrases andsentences. It relies on the principle of compositionality, which states that the meaningof a phrase or a sentence can be derived from the meanings of its parts, guided bysyntactic structure.

(a) What do the following examples demonstrate about the difficulties thatcompositional semantic models face?

(i) it snows

(ii) rock the boat

(iii) enjoy a cigaretteenjoy a book

(iv) inject lifeinject hydrogen

[2 marks each]

(b) Distributional representations of phrases and sentences can be derived bycombining, or composing, the distributional representations of individual wordsin them. Briefly describe:

(i) three limitations of vector mixture models;

(ii) how lexical function models address these limitations.

[3 marks each]

(c) Describe how adjectives can be represented as lexical functions and how suchlexical functions can be learned from a text corpus. [6 marks]

11 (TURN OVER)

Page 12: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.12

12 Optimising Compilers

The following three-address pseudo-code shows a compiler’s intermediate representa-tion of a basic block, with destination registers as the first operand of each non-storeinstruction. The compiler has already determined that there are no aliases betweeninstructions accessing memory (ie: instructions 1, 2, 6, 8, 9 all access different memorylocations).

1: load $1, 0($5)

2: load $2, 8($5)

3: sub $3, $1, $2

4: add $4, $1, $2

5: add $4, $4, #8

6: store $4, 0($3)

7: and $2, $4, #4095

8: load $1, 16($5)

9: store $2, 0($1)

(a) What are the two goals of instruction scheduling? [2 marks]

(b) With reference to the above code, describe the constraints on reorderinginstructions. [4 marks]

(c) Briefly describe an instruction scheduling algorithm, then apply it to this codewhen targeting a simple 5-stage pipelined processor (IF, RF, EX, MEM, WB),showing the time saving against the original schedule. You may assume eachinstruction takes one cycle to execute and that the hardware supports delayedloads with feed-forwarding and interlocks. [8 marks]

(d) How does register allocation interact with instruction scheduling? [3 marks]

(e) Assuming that all registers are dead at the end of this code, are more registersrequired to schedule this basic block without any stalls? Justify your answer.

[3 marks]

12

Page 13: COMPUTER SCIENCE TRIPOS Part II - University of CambridgeCOMPUTER SCIENCE TRIPOS Part II Tuesday 6 June 2017 1.30 to 4.30 COMPUTER SCIENCE Paper 7 Answer ve questions. Submit the answers

CST2.2017.7.13

13 Principles of Communications

(a) The Transmission Control Protocol (TCP) employs a congestion controlalgorithm to respond to feedback about network conditions. Describe threecommon circumstances in which this might not be triggered. [10 marks]

(b) Wikipedia occasionally suffers from so-called “edit wars”, when different authorssuccessively alter content, backwards and forwards, between two differentviewpoints. How would you design a system to stabilize such behaviour byintroducing negative feedback controls to slow down or even stop the ability ofsuch authors to make edits to articles in this situation? A qualitative answeridentifying the features of such a system will suffice. [10 marks]

14 Security II

(a) Single Sign-On systems (SSO) may be classified (after Pashalidis and Mitchell)as either pseudo-SSO or true-SSO, and as either local or proxy-based. Thesetwo dimensions partition the space of SSO systems into 4 quadrants.

(i) After describing what an SSO is and the purpose it serves, explain theterms “pseudo-SSO”, “true-SSO”, “local” and “proxy-based”. [4 marks]

(ii) Describe an example SSO system for each quadrant (real or imaginary, butwith a concrete use case), briefly sketching how it works. [8 marks]

(iii) What are the security, privacy, usability and deployability problemsinherent to each of the four quadrants? [8 marks]

END OF PAPER

13