Consider a programming language that consists of commands C…

Question Answered step-by-step Consider a programming language that consists of commands C… Consider a programming language that consists of commands C composed from assignments X := E (where X is a program variable, and E is an arithmetic expression), heap allocation X := alloc(E1, . . . , En), heap assignment [E1] := E2, heap dereference X := [E], disposal of heap locations dispose(E), the no-op skip, sequencing C1; C2, conditionals if B then C1 else C2 (where B is a boolean expression), and loops while B do C. null is 0 (a) Explain informally what it means for a separation logic partial correctness triple {P} C {Q} to be valid. [3 marks] (b) Explain informally what it means in terms of the executions of C for the separation logic partial correctness triple {>} C {⊥} to be valid. [2 marks] (c) Recall the list representation predicate list: list(t, []) = (t = null) list(t, h :: α) = ∃y.((t 7→ h) ∗ ((t + 1) 7→ y) ∗ list(y, α)) We write [] for the empty mathematical list; h :: α for the mathematical list the head of which is h, and the tail of which is α; α ++ β for the concatenation of mathematical lists α and β; α[i] for the i-th element of the list α, starting at 0; and [k, . . . , n] for the ascending list of integers from k to n, including k and n. Give a proof out invariant, for the following triple: {N = n ∧ N ≥ 0} X := null; while N > 0 do (X := alloc(N, X); N := N − 1) {list(X, [1, . . . , n])} [4 marks] (d) Also recall the partial list representation predicate plist: plist(t, [], u) = (t = u) plist(t, h :: α, u) = ∃y.((t 7→ h) ∗ ((t + 1) 7→ y) ∗ plist(y, α, u)) Give a loop invariant for the following list sum triple: {list(X, α)} Y := X; N := 0; while Y 6= null do (M := [Y ]; N := N + M; Y := [Y + 1]) n list(X, α) ∧ N = Plength(α)−1 i=0 α[i] o [4 marks] (e) Give a loop invariant for the following list concatenation triple: {list(X, α) ∗ list(Y, β)}  if X = null then Z := Y else  Z := X; U := Z; V := [Z + 1]; while V 6= null do (U := V ; V := [V + 1]); [U + 1] := Y   {list(Z, α ++ β)} [5 marks] (f ) Describe precisely a stack and a heap that satisfy list(X, [1, . . . , 3]). [2 marks]Consider the following Java class that is intended to represent a specific day in an eight-week University term. public class TermDay { public int day; // The day of the week as a number 0-6 public int week; // The week of the term as a number 0-7 }; (a) Create  class EncapsulatedTermDay, which applies the principles of data encapsulation as an alternative to TermDay. Your modified class should throw an exception if an invalid day of the week or week number is specified. [4 marks] (b) The use of two int variables to represent the day and the week requires 64 bits of storage. How many bits are actually required? Adapt EncapsulatedTermDay class to achieve the same functionality using only one member variable of a primitive type. You should justify your choice of type. [4 marks] (c) Create  class ImmutableTermDay that is an immutable version of TermDay. [3 marks] (d) By applying one or more appropriate design patterns and adapting ImmutableTermDay appropriately, show how to ensure that only one ImmutableTermDay object is ever created for a given day/week combination. [9 marks](b) Briefly describe how to generate values which are distributed exponentially for use in the simulator. [3 marks] (c) State Little’s Law. Outline a proof of Little’s Law with the aid of a diagram. [7 marks] 4 VLSI chip: (a) single global clock (b) two-phase clock (c) synchronised clock using an on-chip phase-locked loop (d) self-timed logic (no clock) [5 marks each] 2 CST.97.9.3 5 Business Studies Describe the rˆoles and relationships of the members of a Chief Programmer team. [5 marks] Describe Maslow’s Hierarchy of Needs. [5 marks] Discuss stages of group formation. How does belonging to a group satisfy some of the needs described by Maslow? [5 marks] “The problems of co-ordination mean that there is a limit on the size of any software system that can be successfully built.” Discuss. [5 marks] 6 Advanced Algorithms Describe the structure of a Fibonacci heap and explain how to perform the following operations: (a) create an empty heap (b) add a single new node to a heap (c) form the union of two existing heaps  Discuss how neural operators which encode, analyse and represent image structurein natural visual systems can be implemented in artificial neural networks. Includefour of the following issues in your discussion:• receptive field structure• adaptiveness and perceptual learning• hierarchies of tuning variables in successive layers of the visual pathway• wavelet codes for extracting pattern information in highly compressed form• self-similarity of weighting functions• associative memory or content-addressable memory for recognising patternssuch as faces and eliciting appropriate response sequences[20 marks]9 SecurityWrite brief notes on each of the following:(a) the Internet Worm(b) Trojan horses(c) polymorphic viruses(d) virus exploitation of covert channels(e) the distinguishing characteristics of viruses written in interpreted languages  Discuss two possible strategies that you might use to translate the abstract syntaxtree corresponding to an integer expression composed of simple variables, integerconstants and the usual integer operators +, −, ∗ and / into reasonable qualitycode for a machine with eight general-purpose registers.You should pay particular attention to how you would control the allocation ofregisters and anonymous store locations, and you should outline what optimisationsare convenient to perform. [20 marks]7 Artificial Intelligence IIExplain how genetic algorithms differ from conventional mathematical methods foroptimisation. [10 marks]What are the advantages and disadvantages of genetic algorithms? [10 marks]2CST.94.13.38 DatabasesDescribe how a data model is represented in a relational database, and explain howone might specify a relational database schema. [5 marks]What is meant by a referential integrity constraint in a relational database?[3 marks]Each year the number of tourists coming to Cambridge increases by 10%. Mostof the pressure falls on a limited number of identified sites in the city centre. TheTourist Board has restricted the size of any group visiting such a site to 20, andrequires a group of ten people or more to get a permit in advance. Most bookingsare made either by tour operators or directly by independent guides: the TouristBoard will arrange guides for groups if asked to do so.A database is being installed to coordinate bookings and to provide informationabout the opening times of sites. Each site has separate opening times for summerand winter (owing to college autonomy, changes of season differ from site to site).Permits are issued to start on the hour or on the half-hour: they are valid eitherfor 1 hour or for 2 hours, the duration being fixed for each site. The final permitsof each day are timed to expire at the site’s closing time. Each site has a fixedcapacity, and no booking can be accepted that would cause it to be exceeded. Thecharge for a permit depends only on the site and the season. (Occasionally sitesare closed for several hours during the normal opening period, for example whenrecording is taking place in King’s College Chapel. The protocol is to inform theTourist Board at least 6 months in advance.)The Tourist Board issues permits to visit an identified site at a given time on agiven day, specifying the booking agent and the number in the group. Bookingscan be made up to 6 months beforehand. Permits are issued to registered touroperators and guides on account, but in all other cases payment must be made inadvance. The data held for registered guides includes not only account details butalso their working hours and charges.Design a schema for the relational database that is to record this information forthe Tourist Board. You may find it helpful to use domain types DATE, TIME andMONEY in addition to standard programming language datatypes. You do not needto specify the transactions that maintain the database, but you should state clearlyany assumptions that influence the schema design. [12 marks]3 [TURN OVERCST.94.13.49 Specification and Verification of HardwareDiscuss the problems of providing tractable models of transistors suitable forhardware verification by formal proof. Compare and contrast at least two differentmodels. Illustrate your discussion with concrete examples of transistor circuits.[20 marks]10 ComplexityFor each of the following statements state whether the claim made is true, false orif more information is needed before a judgement can be made. Give one-sentencejustifications of your assertions.(a) Sorting a list of numbers into ascending order is an NP problem.(b) Sorting a collection of programs into order so that the ones that finish quicklycome before those that run for a long time is an NP-complete problem.(c) To be NP-complete is to be as difficult as any solvable problem can be.(d) Any NP problem can be solved (on an ordinary computer) in polynomial spaceand exponential time.(e) The problem of determining whether a k-clique is present in a graph is knownto be NP-complete. Therefore for large graphs and large values of k it willalways be impossible (in practice) to find such a clique even if it is known thatone exists.(f ) For the purposes of complexity theory each of the cost functions n log n, n1.573and n! counts as polynomial growth.[20 marks]11 Computation TheoryExplain Turing’s Thesis. [5 marks](a) What is meant by saying that a Turing machine has searching states? Showthat any Turing machine computation can be effected by a machine withsearching states, equivalent in the sense that the head movements are identicaland the same symbols are written to the tape. [5 marks](b) Show that, subject to suitable encoding, any computation can be carried outby a Turing machine having only two states. Define the types and terms of the language PCF. Describe the denotationalsemantics of PCF using domains and continuous functions. In what sense is thedenotational semantics of PCF compositional? [12 marks]Explain the soundness and adequacy properties of the denotational semantics withrespect to the operational semantics of PCF. (A definition of the PCF operationalsemantics need not be given.) [4 marks]Define the notion of contextual equivalence for PCF terms. Explain why thecompositional, soundness and adequacy properties mentioned above imply thatif two closed PCF terms of the same type have equal denotation, then they arecontextually equivalent. [4 marks]11 Information Theory and CodingThe information in continuous but bandlimited signals is quantised, in that suchcontinuous signals can be completely represented by a finite set of discrete numbers.Explain this principle in each of the following four important contexts or theorems.Be as quantitative as possible:(a) The Nyquist Sampling Theorem. [5 marks](b) Logan’s Theorem. [5 marks](c) Gabor Wavelet Logons and the Information Diagram. [5 marks](d) The Noisy Channel Coding Theorem (relation between channel bandwidthW, noise power spectral density N0, signal power P or signal-to-noise ratioP/N0W, and channel capacity C in bits/second). [5 marks]12 Computer VisionDiscuss the rˆole of non-linear operators in vision for the extraction of motioninformation, texture information, colour information, and stereo information.What are the limitations of linear operators (such as filters) compared withnon-linear ones? What is a quadrature pair, and what is a Hilbert pair?What is a Hilbert Transform, and what is a natural way to build a usefulnon-linear operator from it? [20 marks]6CST.97.9.713 TypesGive the syntax of (types and terms of) the second-order polymorphic lambdacalculus λ2 whose five ways of constructing terms, M, are: identifiers, lambdaabstraction, application, type abstraction and type application. (The last two aresometimes known as generalisation and specialisation.) Make it clear which, if any,sub-phrases of terms represent types or type variables. [4 marks]Give a term M conforming to the syntax of λ2 which is not well-typed accordingto the usual inference rules for λ2. [2 marks]Let λU be the untyped lambda calculus whose terms N have syntax:N ::= x | λx.N1| N1N2.Define a function erase : λ2 → λU which removes all types from a λ2 term, butwhich preserves the rest of it.[Hint: erase(Λα.M) = erase(M).] [3 marks]Now find (or briefly justify why this is impossible):(a) two well-typed λ2 terms M1 and M2 without free type variables such thaterase(M1) = erase(M2) = λx.x and that M1 and M2 differ by more than typevariable renaming;(b) a well-typed λ2 term M3 such that erase(M3) = λx.xx;(c) a well-typed λ2 term M4 such that erase(M4) = (λx.xx)(λx.xx);(d) a well-typed λ2 term M5 such that N5 = erase(M5) has no ML type;(e) a λU term N6 which has an ML type, but such that there is no well-typed λ2term M6 with erase(M6) = N6.  using c programing Write program to calculate the average of a set of students (we don’t know their count) (using functions)write program to print Hello world in C language. post screen shot after doing in computer Explain the term positive semi-definite. [1 mark]Let A be a square matrix. State Schwarz’s inequality for the product Ax. Whatare the singular values of A, and how are they related to the `2 norm of A?[4 marks]Describe briefly the singular value decomposition of the matrix A, and how it maybe used to solve the linear equations Ax = b. [4 marks]Let xˆ be an approximate solution of Ax = b, and write r = b − Axˆ, e = x − xˆ.Find an expression for the relative error kek/kxk in terms of computable quantities.Show how your formula is related to the singular values of A. [8 marks]How may this formula be used if some singular values are very small? [3 marks]15 Communicating Automata and Pi CalculusDefine the notions of sort and sorting for the π-calculus, and explain what is meantby the assertion that a process P respects a sorting. Give two reasons why sortingis useful. Simple data values can be represented as abstractions in the π-calculus. Inparticular, if True and False are abstractions representing the two truth-values,then b.True, b.False are processes in which each truth-value is located at b.Define the abstractions True and False. Also, for arbitrary processes P and Q,define the abstraction CASES(P, Q) such thatCASES(P, Q)hbi | b.True −→∗PCASES(P, Q)hbi | b.False −→∗ Qand demonstrate these reductions. Give a sorting respected by all theseconstructions.  ) A data object exists in persistent memory.(i) A single operation is invoked on it in response to a request from a client.The result of the invocation is output to the client.How can the operation be made atomic? [4 marks](ii) A client requests a high-level operation which comprises more than oneof the type operations on the data object.How can the high-level operation be made atomic? [8 marks]3 [TURN OVERCST.93.5.48 DatabasesDescribe the relational model of data. [4 marks]What is meant by a candidate key? [2 marks]Explain what it means for a relational data model to be presented in(a) Third Normal Form (3NF) [5 marks](b) Fourth Normal Form (4NF) [5 marks]in each case illustrating your answer with a suitable example data model.In what circumstances might it not be sensible to hold relational data according tothese normal forms? [4 marks]SECTION C9 Foundations of Functional ProgrammingDescribe how the λ-calculus models the operations of addition, test for zero andsuccessor, representing the natural numbers by Church numerals. [4 marks]The Fibonacci sequence is defined by F0 = 0, F1 = 1 and Fk = Fk−1 + Fk−2for k > 2. Present a λ-term fib that computes the Church numeral for Fk giventhe Church numeral for k, for all k > 0. Do not use Y or any other fixed pointcombinator. You may take as primitive the λ-calculus encodings of standard datastructures. [6 marks]Describe how to assign G¨odel numbers to λ-terms and explain the notation pMq.Describe an application of these techniques. [3 marks]Present a λ-term iszero, such thatiszeropMq =true if M = 0false if M 6= 0or prove that no such term exists. [7 marks]4CST.93.5.510 Computation TheoryShow that there is no way of deciding by algorithms whether a general registermachine program with code p will terminate when started with initial data of 0 inevery register. [10 marks]Show that there is no way of deciding by algorithm whether the blank character willbe printed during the course of a general Turing machine computation. [10 marks]Note: any standard form of the undecidability result for the general halting problemmay be assumed, but should be stated clearly.11 Complexity TheoryExplain how to measure the size of a problem in complexity theory. [3 marks]What is meant by reducing one problem to another? [4 marks]Given that the Boolean Satisfiability Problem is NP-complete, show that theHamiltonian Circuit Problem for undirected graphs is also NP-complete.[13 marks]12 Formal Languages and AutomataExplain what is meant by a regular expression over an alphabet Σ, and by thelanguage L(r) denoted by such a regular expression r. [5 marks]For any regular expressions r, s, t, show that if L(r) contains L(t|sr) then it alsocontains L(s*t). [5 marks]Assuming that the empty string ε is not in L(s), show that if L(r) = L(t|sr) thenL(r) = L(s*t). Hint: argue by induction on the length of strings in L(r). [5 marks]Give an example to show that the above assumption ε 6∈ L(s) is necessary.[3 marks]Deduce that when ε 6∈ L(s), r and t|sr denote the same language if and only if r ands*t denote the same language. import java.util.Scanner; public class Client{ public static void main(String args[DX Coin quarter = new Coin(25); Coin dime = new Coin(10); Coin nickel = new Coin(5); Scanner keyboard = new Scanner(System.in); inti 0 int total = 0; whiletrue) i+ System.out.printin(“‘Round “+ i+ “: “); quarter.toss); System.outprintln(“Quarter is ” quarter.getSideUp0); while(true)X i++ System.out.println(“Round ” +i+” “); quarter.toss0; System.out.printin(“‘Quarter is ” +quarter.getsidelUp0)% if(quarter.getSideUp) == “HEADS”) total = total +quarter.getvalue0; dime.toss0: System.out.println(“Dime is” + dime.getSideUp0); if(dime.getSideUp0 == “HEADS) total = total +dime,.getvalue| nickel.toss0; System.out.printin(“‘Nickel is” + nickel.getsideUp0)% if(nickel.getSideUp) = = “HEADS”)kindly answer all the questions Computer Science Engineering & Technology C++ Programming CIVIL 123 Share QuestionEmailCopy link Comments (0)