The Bully Algorithm allows a set of nodes to elect a unique leader…

QuestionAnswered step-by-stepThe Bully Algorithm allows a set of nodes to elect a unique leader…The Bully Algorithm allows a set of nodes to elect a unique leader in the presence of node failures. For the purposes of this question, assume that: the set of nodes is known in advance by all nodes; each process knows its own identifier; processes fail and restart cleanly; node failure can be reliably detected; and message delivery is reliable unless the destination node has failed. Our network contains eight nodes (1-8), which are connected via three switches (A-C) Node 1 Switch A Switch B Switch C Node 2 Node 3 Node 4 Node 5 Node 6 Node 7 Node 8 (a) In the absence of node or switch failures, which node will be elected leader using the Bully Algorithm? [1 mark] (b) A new Node 9 is added to the network, attached to Switch C. Which node will be elected leader using the Bully Algorithm? [1 mark] (c) If there is a network partition between Switches B and C, what node will be elected leader using the Bully Algorithm? [2 marks] (d) To address the concern about network partition, the authors of a distributed system introduce a majority rule: for a node to declare itself leader, it must receive OK messages from a majority of nodes (including itself). Which combinations of links can fail while still permitting a successful election, and, for each of those combinations, which node is elected leader? [4 marks] (e) One key metric used in evaluating distributed algorithms is the number of messages generated. What is the worst-case cost (using O-notation) in messages with n nodes participating in the Bully Algorithm? Explain why this is the case. [2 marks] (f ) The Bully Algorithm provides a strong invariant that a node can identify that it is the unique leader in a distributed system. However, that leadership status can be preempted (revoked) without node failure. Explain how this may occur. [4 marks] (g) Describe how a distributed application can utilise elected leadership status to safely allocate unique transaction IDs. Explain why this works, considering in particular: (1) the steady state; (2) leader change due to leader crash; and (3) leader change due to leadership revocation. [6 marksConsider the access rights of user alice regarding the following files and directories on a Linux file system: $ id uid=1000(alice) gid=1000(alice) groups=505(safety) $ ls -ld foo foo/* foo/*/* drwxrwxrwx 4 root root 4096 Apr 20 14:40 foo -rw-rw-r– 1 root root 100 Apr 20 14:40 foo/bar -rw-rw drwx—— 2 root root 4096 Apr 20 14:40 foo/dir1 drwxrwxr-t 2 root alice 4096 Apr 20 14:40 foo/dir2 -rw-rw—- 1 root root 100 Apr 20 14:40 foo/dir2/flop -rw-rw-r– 1 alice alice 100 Apr 20 14:40 foo/dir2/wibble -rw-rw—- 1 root safety 100 Apr 20 14:40 foo/dir2/wobble (i) For each of the eight files and directories under foo/, list which of the following three operations user alice is able to perform: read (R), delete (D), rename (N). Your answer should be eight lines of the form R-N foo/qux where the letters RDN indicate that the corresponding operation is allowed, and replacing any of these letters with – indicates that it is denied. [8 marks] (ii) Which sequence of shell commands can user alice use to take ownership of file foo/bar, without affecting its content, such that it appears afterwards in the above directory listing as in -rw-rw-r– 1 alice alice 100 Apr 20 14:40 foo/bar [2 marks] (iii) Name two operations on the metadata of file foo/bar that user alice can execute only after taking ownership. [2 marks] (b) List four mechanisms that a web server can use to maintain authentication session state across a web browser’s HTTP requests that form part of the same login session, along with one disadvantage associated with each.Most modern computers include a translation lookaside buffer (TLB) to speed up address translation. (a) Describe with the aid of a diagram the basic operation of a TLB. [2 marks] (b) Some TLBs support process tags (sometimes called address space numbers). Explain how process tags could be used by an operating system, and what benefits might be expected. [2 marks] (c) Some TLBs support superpages of one or more sizes. (i) Explain how superpages could be used to reduce the TLB footprint for operating system kernels. [2 marks] (ii) Explain how superpages could be used to reduce the TLB footprint for processes. What additional considerations need to be taken into account in this case? How well do you think your scheme would work in practice? [4 marks] (d) Compare and contrast the way in which demand paging is performed in Unix and VMS. [10 marks] (a) Write  immutable Java class Complex that represents a complex number with integer real and imaginary components. [Note: Your class should contain only methods that are essential for its use. Do not incorporate any mathematical operations in the class.] [4 marks] (b) Without using Generics, adapt the class to support the use of arbitrary types to store the real and imaginary components. Give three disadvantages of this approach and comment on the immutability of the new class. [7 marks] (c) Rewrite your class from part (b) using Generics. Discuss the extent to which this new version addresses the problems identified in part (b). [7 marks] (d) Explain carefully why the following code cannot be used to print out an object of type LinkedList>. You may assume the existence of a working print method within each Complex object. void printAll(LinkedList> list) { for (Complex c : list) c.print();  Cons cumulative reward, a policy, and an optimal policy for a problem of this kind. [5 marks] (b) Give a detailed derivation of the Q-learning algorithm. [5 marks] (c) In the reinforcement learning problem shown in the diagram, states are positions on a grid and actions are down and right. The initial state is s1. The only way an agent can receive a (non-zero) reward is by moving into one of two special positions, one of which has reward ?50 and the other 150. s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 150 ?50 A possible sequence of actions (sequence 1) is shown by solid arrows, and another (sequence 2) by dashed arrows. Assume that all Q values are initialised at 0. Explain how the Q values are modified by the Q-learning algorithm if sequence 1 is used once, followed by two uses of sequence 2, and then one final use of sequence 1. [10 marks]The following code has been written by a novice Java programmer. You are not required either to understand or to debug the details of how this code draws some particular pattern (a “Dragon”). The programmer finds that the Java compiler complains. Identify any errors and comment on any issues that (even if not strictly invalid Java) are liable to cause problems. You are not required to provide corrections.pper class Dragon extends JApplet throws Exception { import javax.swing.*; public paint(Graphics g) { this.g = g; drawDragtle: drawDragon Function to draw a dragon curve between too points (x1,y1) and (x2,y2) with depth ‘depth’. */ void protected drawDargon(int depth, int x1,int y1,int x2,int y2) { if (x1 < 0 | x2 < 0) if (y1 < 0) raise new Exception("X & Y < 0"); else assert("Ok so far"); if (depth = 0) // bottom of recursion { (y2+y1-x2+x1)/2; ... and Y coord. */ printf("DEBUG: x= drawDragon(depth-1,mpx,mpy,x1,y1); drawDragon(depth+1,mpx,mpy,x2,y2); } static secret int DRAWDEPTH=15, Graphics g; (a) Show how you would create  Java array of 1000 integer values. [1 mark] (b) The values in an array could be used to represent digits in the decimal representation of a number. For example, the number 1 7 has decimal representation 0.142857 . . . and that could be stored in an array whose elements started {1, 4, 2, . . .}. For a number stored that way write code that multiplies the number by a given integer, returning the whole number part of the result and leaving the array updated to hold the fractional part of the product. [5 marks] (c) To convert a fraction to a representation base 16 (i.e. hexadecimal) you can multiply it by 16, and the resulting integer part is the first digit of the base-16 representation. Multiplying the fraction left over by 16 gets the second digit and so on. Write  method that accepts an array of digits (base 10) and creates and returns a new array representing the same fraction but now base 16. Your code should work for any length input array, not just one of length 1000, and you may make the output array have the same length as your input array. [6 marks] (d) Suppose the input to your method in part (c) was of length 1000 and started off with the decimal digits of 1 7 in it. Although the initial digits in the output array are the correct hexadecimal representation of 1 7 the last few end up looking odd. Explain. [3 marks] (e) One way to ensure that numerical results are correct is to use interval arithmetic. A value is represented as a pair of arrays, one representing a number less than (or equal to) the true value and one a value greater than it. So if using 6 decimal places the number 1 7 would be held as a pair { If the two final digits differ by at most 1 then the smaller of them can be viewed as fully accurate. Using this idea, write code that accepts a fraction in decimal form and returns a vector denoting the same value in another base n (now no longer necessarily 16) such that all the digits in the result vector are correct. Clarity in your code is to be preferred to performance, but if you are aware of particular ways in which the code you present is particularly inefficient, you should note and explain themFor each of the following pairs of concepts that are used in Java explain similarities and differences and discuss when you would use one rather than the other. If there are important syntactic differences, method names, degrees of generalisation possible or the like, then any code fragments you give in illustration should be as short as possible to make the desired point. (a) JApplet and simple Java applications [4 marks] (b) Vector and arrays of strings (String []) [3 marks] (c) class, abstract class and interface(a) In order to remove the overhead of a function call, a programmer decides to replace all calls to a function f with the macro F, where f and F are defined as follows: int f(int x) { return x+x;} #define F(X) (X)+(X) (i) Give two valid C expressions involving f which produce different results when F is substituted for f. Justify your answer. [4 marks] (ii) State the C language feature which can be used to correctly remove the overhead of a function call. [1 mark] (b) Consider the following: static struct link { int v; struct link *next; } *head=0; void convert(int a[], int len); Write  function definition for convert which updates head to point to a linked-list containing the elements of a in the same order. You may assume len contains the number of elements in a. [5 marks] (c) Consider the following C++ declaration: template int SumSquares(); (i) Using function specialisation, provide an implementation of SumSquares so that, given an integer N, SumSquares() returns: X N i=1 i 2 [5 marks] (ii) Compare and contrast the functionality of the C preprocessor and the C++ template system. Explain why it is not possible to write a C preprocessor macro to implement SumSquares. [5 marks] (a) An author writes: Most successful language design efforts share three important characteristics . . . 1. Motivating Application: The language was designed so that a specific kind of program could be written more easily. 2. Abstract Machine: There is a simple and unambiguous program execution model. 3. Theoretical Foundations: Theoretical understanding was the basis for including certain capabilities and omitting others. Briefly discuss the merits and/or shortcomings of one of the above three statements of your choice, giving examples and/or counterexamples from procedural, applicative, logical, and/or object-oriented programming languages. [6 marks] (b) For two programming languages of your choice amongst FORTRAN, Algol, Pascal and C, briefly discuss and evaluate their typing disciplines. Further compare the advantages and disadvantages that their designs impose on the programmer. [5 marks] (c) Consider the following two program fragments. ( defvar x 1 ) ( defun g(z) (+ x z) ) ( defun f(y) (+ (g 1) ( let ( ( x (+ y 3) ) ) ( g(+ y x) ) ) ) ) ( f 2 ) val x = 1 ; fun g(z) = x + z ; fun f(y) = g(1) + let val x = y + 3 in g(y+x) end ; f(2) ; What are their respective output values when run in their corresponding interpreters? Justify your answer, explaining it in a conceptual manner. [4 marks] (d) Outline the key features that a language must have to be called object-oriented. Further, briefly discuss to what extent one programming language of your choice amongst Simula, Smalltalk, C++, and Java has them. [5 marks(a) Many computer scientists believe that languages with strong compile-time type checking are better than those that are typeless, dynamically typed, or are weakly type checked. Discuss the reasons for this view. [7 marks] (b) If strictly-checked data types are seen as good, discuss whether augmenting a language with many more primitive data types is better. Consider, in particular, the possibility of incorporating into a language such as Java many new numerical types such as packed decimal of various precisions, scaled arithmetic, and new types to hold values representing distance, mass and time. How would these additions affect the readability and reliability of programs? [7 marks] (c) Some languages allow different modes of calling of function arguments, such as call by value, call by reference and call by name. Discuss the advantages and disadvantages of incorporating the argument calling modes into the data types of functions. [6 marks] (a) State what is meant by a directed graph and a strongly connected component.Illustrate your description by giving an example of such a graph with 8 verticesand 12 edges that has three strongly connected components. [5 marks](b) Describe, in detail, an algorithm to perform a depth-fifirst search over such agraph. Your algorithm should attach the discovery and fifinishing times to eachvertex and leave a representation of the depth-fifirst spanning tree embeddedwithin the graph. [5 marks](c) Describe an O(n) algorithm to discover all the strongly connected componentsof a given directed graph and explain why it is correct. You may fifind it usefulto use the concept of the forefathepathfrom v to u. [10 marks]2 Computer Design(a) What is a data cache and what properties of data access does it exploit?[5 marks](b) What is a direct mapped cache and under what conditions will it exhibit poorperformance? [5 marks](c) Under what circumstances might a word of data in main memory besimultaneously held in two separate fifirst-level cache lines? [5 marks](d) A translation look aside buffffer is a specialised cache. What does it typicallystore and why is it often a factor of 1000 smaller than a data cache? [5 marks]2CST.2001.6.33 Digital Communication I(a) Defifine the terms circuit and packet in the context of communication systems.[5 marks](b) What sort of guarantee does circuit switching provide? [5 marks](c) What advantages does packet switching provide over circuit switching?[5 marks](d) Which of frequency division multiplexing, time division multiplexing and codedivision multiplexing lend themselves to circuit switching? Which to packetswitching? Explain why or why not in each case. [5 marks]4 Computer Graphics and Image Processing(a) Describe the z-buffffer polygon scan conversion algorithm. [10 marks](b) In ray tracing, once we have determined where a ray strikes an object, theillumination at the intersection point can be calculated using the formula:I = Iaka +XiIikd(Li · N) +XiIiks(Ri · V)nExplain what real effffect each of the three terms is trying to model and explainwhat each of the following symbols means, within the context of this formula:I, Ia, i, Ii , ka, kd, ks,Li, N, Ri, V, n[10 marks]3[TURN OVERCST.2001.6.4SECTION B5 Comparative Programming Languages(a) Brieflfly explain the concept of coroutines as used in BCPL and outlinethe effffect of the library functions createco(f, size), deleteco(ctpr),callco(cptr, val) and cowait(val). [10 marks](b) Outline how you would design a coroutine to merge, in increasing order, twoinfifinite streams of increasing integers supplied by two other coroutines.[5 marks](c) Brieflfly outline how you would implement an analogous merging mechanism inan object-oriented language, such as Java, that does not provide a coroutinemechanism. [5 marks]6 Compiler Construction(a) Describe one possible structure (e.g. ELF) of an object fifile. Illustrate youranswer by considering the form of object fifile which might result from thefollowing C program.int a = 1, b = -1;extern int g(int);extern int c;int f() { return g(a-b) + c; }It is not necessary to consider the exact instruction sequence, just issuesconcerning its interaction with the object fifile format. [10 marks](b) Describe how a linker takes a sequence of such programs and produces anexecutable fifile. [4 marks](c) Compare and contrast static and dynamic linking in a system using your objectfifile format. [6 marks]4CST.2001.6.57 Prolog for Artifificial IntelligenceA weighted binary tree can be defifined using compound terms in the following way.A node of the tree is represented by the term n(V, L, R), where V stands for thevalue of the node, and L and R stand for the left and right branches, respectively.A terminal node has the R and L components instantiated to the null list.Given an input tree T, write a Prolog program that constructs a tree of the sameshape as T, but in which the value of each node has been set to the value of themaximum value node in T.[Note: Maximum marks are available only for programs that perform this task inone recursive descent of the input tree, and which use no more than four clauses.][20 marks]5[TURN OVERCST.2001.6.68 DatabasesThe environmental agency is setting up an SQL database to monitor long-termtrends in the climate. Data are collected from observatories of a number of difffferentkinds.Flood risk is of particular concern. Each water authority measures river levels andrates of flflow hourly at major points, and records reservoir levels daily.In addition, the agency maintains weather stations both inland and at sea. Theserecord precipitation (rainfall etc.), temperature, sunshine, air pressure and wind.Values of new precipitation, temperature, pressure, and wind speed and directionare taken hourly; gusts of over 60 m.p.h. are noted whenever they occur.Maximum and minimum temperature and pressure, the total number of hours ofsunshine and the total precipitation are recorded daily. Inland stations can begrouped by water authority.By default these primary data will be relegated to archive after 2 years. Selectedinformation is retained permanently in a data warehouse. This serves two purposes.First, it holds monthly summary data consisting of the maximum (and minimumas appropriate) day value for each statistic, together with the monthly totals ofsunshine and precipitation. The warehouse also keeps detailed information relatingto periods of extreme weather from the relevant observatories, with one or morekeywords describing the nature of the incident (flflood, blizzard, hurricane etc.) andan optional comment.Write notes to assist in the design of the schema for the relational data warehouse,including any diagrams that you fifind helpful. Explain how your design will enablemeteorologists to fifind relevant past records, noting any assumptions that you makeabout the nature of the data.[You should not go into unnecessary detail about the structure of the primarydatabase. You may assume that expert meteorologists will select the data for thewarehouse.][20 marks]6CST.2001.6.7SECTION C9 Semantics of Programming LanguagesWrite short notes on four of the following fifive topics.(a) The relationship between three forms of operational semantics of the Languageof Commands (LC) given by• an evaluation relation h P, si ? hV, s0 i• a transition relation h P, si ? hP0 , s0 i• a transition relation between the confifigurationsh c, r, si of theSMC-machine(b) The notion of semantic equivalence of LC phrases and its congruence property.(c) Call-by-name and call-by-value rules for evaluating function applications in theLanguage of Functions and Procedures (LFP) and the relationship between theevaluation relations for LFP based upon each of them.(d) The notion of bisimilarity of two confifigurations in a labelled transition system.(e) The rules defifining the possible labelled transitions of parallel composition(P1|P2) and restriction (? c . P) in the Language of Communicating Processes(LCP).[5 marks each]7[TURN OVERCST.2001.6.810 Foundations of Functional ProgrammingThe following are some concepts that have flflourished in the context of functionalprogramming but which have (so far) been less heavily used in main-streamlanguages even when they have been available:(a) polymorphic types(b) type reconstruction(c) higher-order functions(d) lazy evaluation(e) continuationsFor each case give a brief explanation of the facility referred to, suggest acircumstance in which it might be useful and comment on how immediately relevantto non-functional languages it seems.[4 marks per part]8CST.2001.6.911 Logic and Proof(a) In the context of clause-based proof methods, defifine the notion of pure literaland describe what should be done if the set of clauses contains pure literals.[3 marks](b) Use the Davis-Putnam method to discover whether the following set of clausesis satisfifiable. If they are satisfifiable, show a satisfying interpretation.{P, R} {¬P, ¬R} {P, ¬Q} {¬Q, R} {¬P, Q, R}[6 marks](c) The three-fifingered inhabitants of the planet Triterra build base-3 computers.A Triterran named Randal Tryant has found a way of verifying base-3combinational logic. His Ordered Ternary Decision Diagrams (OTDDs) arethe same as a technology used on planet Earth except that all variables andexpressions range over the values 0, 1 and 2 instead of just 0 and 1.(i) Describe how a full ternary decision tree can be reduced to an OTDDwithout regard for effiffifficiency. [2 marks](ii) Sketch an effiffifficient algorithm to convert a ternary expression directly to anOTDD without constructing the full decision tree. For a typical ternaryconnective use modulo-3 multiplication, written as ?. [6 marks](iii) Demonstrate your algorithm by applying it to the ternary expression((i ? i) ? j) ? 2. [3 marks]9[TURN OVERCST.2001.6.1012 Complexity Theory(a) Show that any language that can be accepted by a nondeterministic machinein time f(n) can also be decided by a deterministic machine in space O(f(n)).[4 marks](b) Show that any language that can be accepted by a nondeterministic machinein space f(n) can also be decided by a deterministic machine in timeO(c(f(n)+log n) ), for some constant c. [6 marks](c) Explain what the above results tell us about the inclusion relationships amongthe complexity classes:NL, co-NL, P, NP, PSPACE and NPSPACE[4 marks](d) It has been proved that the graph reachability problem is in co-NL. Whatfurther inclusions can you derive among the above complexity classes usingthis fact? Explain your answer.(a) State what is meant by a directed graph and a strongly connected component.Illustrate your description by giving an example of such a graph with 8 verticesand 12 edges that has three strongly connected components. [5 marks](b) Describe, in detail, an algorithm to perform a depth-fifirst search over such agraph. Your algorithm should attach the discovery and fifinishing times to eachvertex and leave a representation of the depth-fifirst spanning tree embeddedwithin the graph. [5 marks](c) Describe an O(n) algorithm to discover all the strongly connected componentsof a given directed graph and explain why it is correct. You may fifind it usefulto use the concept of the forefather ?(v) of a vertex v which is the vertex, u,with highest fifinishing time for which there exists a (possibly zero length) pathfrom v to u. [10 marks]2 Computer Design(a) What is a data cache and what properties of data access does it exploit?[5 marks](b) What is a direct mapped cache and under what conditions will it exhibit poorperformance? [5 marks](c) Under what circumstances might a word of data in main memory besimultaneously held in two separate fifirst-level cache lines? [5 marks](d) A translation look aside buffffer is a specialised cache. What does it typicallystore and why is it often a factor of 1000 smaller than a data cache? [5 marks]2CST.2001.6.33 Digital Communication I(a) Defifine the terms circuit and packet in the context of communication systems.[5 marks](b) What sort of guarantee does circuit switching provide? [5 marks](c) What advantages does packet switching provide over circuit switching?[5 marks](d) Which of frequency division multiplexing, time division multiplexing and codedivision multiplexing lend themselves to circuit switching? Which to packetswitching? Explain why or why not in each case. [5 marks]4 Computer Graphics and Image Processing(a) Describe the z-buffffer polygon scan conversion algorithm. [10 marks](b) In ray tracing, once we have determined where a ray strikes an object, theillumination at the intersection point can be calculated using the formula:I = Iaka +XiIikd(Li · N) +XiIiks(Ri · V)nExplain what real effffect each of the three terms is trying to model and explainwhat each of the following symbols means, within the context of this formula:I, Ia, i, Ii , ka, kd, ks,Li, N, Ri, V, n[10 marks]3[TURN OVERCST.2001.6.4SECTION B5 Comparative Programming Languages(a) Brieflfly explain the concept of coroutines as used in BCPL and outlinethe effffect of the library functions createco(f, size), deleteco(ctpr),callco(cptr, val) and cowait(val). [10 marks](b) Outline how you would design a coroutine to merge, in increasing order, twoinfifinite streams of increasing integers supplied by two other coroutines.[5 marks](c) Brieflfly outline how you would implement an analogous merging mechanism inan object-oriented language, such as Java, that does not provide a coroutinemechanism. [5 marks]6 Compiler Construction(a) Describe one possible structure (e.g. ELF) of an object fifile. Illustrate youranswer by considering the form of object fifile which might result from thefollowing C program.int a = 1, b = -1;extern int g(int);extern int c;int f() { return g(a-b) + c; }It is not necessary to consider the exact instruction sequence, just issuesconcerning its interaction with the object fifile format. [10 marks](b) Describe how a linker takes a sequence of such programs and produces anexecutable fifile. [4 marks](c) Compare and contrast static and dynamic linking in a system using your objectfifile format. [6 marks]4CST.2001.6.57 Prolog for Artifificial IntelligenceA weighted binary tree can be defifined using compound terms in the following way.A node of the tree is represented by the term n(V, L, R), where V stands for thevalue of the node, and L and R stand for the left and right branches, respectively.A terminal node has the R and L components instantiated to the null list.Given an input tree T, write a Prolog program that constructs a tree of the sameshape as T, but in which the value of each node has been set to the value of themaximum value node in T.[Note: Maximum marks are available only for programs that perform this task inone recursive descent of the input tree, and which use no more than four clauses.][20 marks]5[TURN OVERCST.2001.6.68 DatabasesThe environmental agency is setting up an SQL database to monitor long-termtrends in the climate. Data are collected from observatories of a number of difffferentkinds.Flood risk is of particular concern. Each water authority measures river levels andrates of flflow hourly at major points, and records reservoir levels daily.In addition, the agency maintains weather stations both inland and at sea. Theserecord precipitation (rainfall etc.), temperature, sunshine, air pressure and wind.Values of new precipitation, temperature, pressure, and wind speed and directionare taken hourly; gusts of over 60 m.p.h. are noted whenever they occur.Maximum and minimum temperature and pressure, the total number of hours ofsunshine and the total precipitation are recorded daily. Inland stations can begrouped by water authority.By default these primary data will be relegated to archive after 2 years. Selectedinformation is retained permanently in a data warehouse. This serves two purposes.First, it holds monthly summary data consisting of the maximum (and minimumas appropriate) day value for each statistic, together with the monthly totals ofsunshine and precipitation. The warehouse also keeps detailed information relatingto periods of extreme weather from the relevant observatories, with one or morekeywords describing the nature of the incident (flflood, blizzard, hurricane etc.) andan optional comment.Write notes to assist in the design of the schema for the relational data warehouse,including any diagrams that you fifind helpful. Explain how your design will enablemeteorologists to fifind relevant past records, noting any assumptions that you makeabout the nature of the data.[You should not go into unnecessary detail about the structure of the primarydatabase. You may assume that expert meteorologists will select the data for thewarehouse.][20 marks]6CST.2001.6.7SECTION C9 Semantics of Programming LanguagesWrite short notes on four of the following fifive topics.(a) The relationship between three forms of operational semantics of the Languageof Commands (LC) given by• an evaluation relation h P, si ? hV, s0 i• a transition relation h P, si ? hP0 , s0 i• a transition relation between the confifigurationsh c, r, si of theSMC-machine(b) The notion of semantic equivalence of LC phrases and its congruence property.(c) Call-by-name and call-by-value rules for evaluating function applications in theLanguage of Functions and Procedures (LFP) and the relationship between theevaluation relations for LFP based upon each of them.(d) The notion of bisimilarity of two confifigurations in a labelled transition system.(e) The rules defifining the possible labelled transitions of parallel composition(P1|P2) and restriction (? c . P) in the Language of Communicating Processes(LCP).[5 marks each]7[TURN OVERCST.2001.6.810 Foundations of Functional ProgrammingThe following are some concepts that have flflourished in the context of functionalprogramming but which have (so far) been less heavily used in main-streamlanguages even when they have been available:(a) polymorphic types(b) type reconstruction(c) higher-order functions(d) lazy evaluation(e) continuationsFor each case give a brief explanation of the facility referred to, suggest acircumstance in which it might be useful and comment on how immediately relevantto non-functional languages it seems.[4 marks per part]8CST.2001.6.911 Logic and Proof(a) In the context of clause-based proof methods, defifine the notion of pure literaland describe what should be done if the set of clauses contains pure literals.[3 marks](b) Use the Davis-Putnam method to discover whether the following set of clausesis satisfifiable. If they are satisfifiable, show a satisfying interpretation.{P, R} {¬P, ¬R} {P, ¬Q} {¬Q, R} {¬P, Q, R}[6 marks](c) The three-fifingered inhabitants of the planet Triterra build base-3 computers.A Triterran named Randal Tryant has found a way of verifying base-3combinational logic. His Ordered Ternary Decision Diagrams (OTDDs) arethe same as a technology used on planet Earth except that all variables andexpressions range over the values 0, 1 and 2 instead of just 0 and 1.(i) Describe how a full ternary decision tree can be reduced to an OTDDwithout regard for effiffifficiency. [2 marks](ii) Sketch an effiffifficient algorithm to convert a ternary expression directly to anOTDD without constructing the full decision tree. For a typical ternaryconnective use modulo-3 multiplication, written as ?. [6 marks](iii) Demonstrate your algorithm by applying it to the ternary expression((i ? i) ? j) ? 2. [3 marks]9[TURN OVERCST.2001.6.1012 Complexity Theory(a) Show that any language that can be accepted by a nondeterministic machinein time f(n) can also be decided by a deterministic machine in space O(f(n)).[4 marks](b) Show that any language that can be accepted by a nondeterministic machinein space f(n) can also be decided by a deterministic machine in timeO(c(f(n)+log n) ), for some constant c. [6 marks](c) Explain what the above results tell us about the inclusion relati