(a) Briefly explain the concept of coroutines as used in BCPL and…

QuestionAnswered step-by-step(a) Briefly explain the concept of coroutines as used in BCPL and…(a) Briefly explain the concept of coroutines as used in BCPL and outline the effect 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, two infinite streams of increasing integers supplied by two other coroutines. [5 marks] (c) Briefly outline how you would implement an analogous merging mechanism in an object-oriented language, such as Java, that does not provide a coroutine mechanism. (a) Brieflfly explain the difffferences between combinational and sequential logic.[2 marks](b) With the aid of appropriate diagrams, brieflfly explain the operation of Mooreand Mealy fifinite state machines and highlight their difffferences. [6 marks](c) The state sequence for a binary counter is as follows: The counter is to be implemented using four synchronously clocked D-typeflflip-flflops.(i) Draw a state table for the counter, showing the required D inputs.[4 marks](ii) Find expressions for the D inputs, making use of unused states ifappropriate. [6 marks](iii) What problem could occur when the counter circuit is powered-up? Givetwo possible general methods for overcoming the problem. [2 marks]2CST.2008.2.32 Digital Electronics(a) With the aid of relevant diagrams, show the effffect on the output of acombinational logic circuit of a:(i) static hazard;(ii) dynamic hazard. [3 marks](b) Simplify the following expressions using Boolean algebra:(i) X = (A + B + A . B).(A + B). A . B(ii) Y = (A + B + A . B). C[4 marks](c) Given:F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D(i) Show using a Karnaugh map that F can be simplifified toF1 = A . B + A . B + A . C + B . C . D[2 marks](ii) Show that there are a total of four possible expressions for F. [3 marks](iii) Show how F1 can be implemented using NAND gates and draw the circuitdiagram. Assume that complemented input variables are available.[2 marks](iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaughmap-based approach. [2 marks](v) Now implement F1 assuming that only 2-input NAND gates are available.[4 marks]3 (TURN OVER)CST.2008.2.4SECTION B3 Discrete MathematicsLet X and Y be sets. You are reminded that a relation from X to Y is a subset ofthe product X × Y .(a) Explain what it means for a relation f from X to Y to be a function, aninjection and a surjection from X to Y . [4 marks](b) A bijection from X to Y is defifined to be a function from X to Y which isboth an injection and a surjection. Prove that a function f from X to Y is abijection iffff it has an inverse function g, i.e. g is a function from Y to X suchthat g ? f = idX and f ? g = idY .[Remember to prove both the “if” and “only if” parts of the assertion.][12 marks](c) Describe, without proof, a bijection from P(X × Y ) to (X ? P(Y )) and itsinverse. [4 marks]4CST.2008.2.54 Discrete MathematicsLet I be a non-empty subset of the natural numbers N = {1, 2, 3, · · ·}.The set S is defifined to be least subset of N such thatI ? S, andif m, n ? S and m < n, then (n ? m) ? S.Defifine h to be the least member of S. This question guides you through to a proofthat h coincides with the highest common factor of I, written hcf (I), and defifinedto be the natural number with the properties thathcf (I) divides n for every element n ? I, andif k is a natural number which divides n for every n ? I, then kdivides hcf (I).[Throughout this question you may assume elementary facts about division.](a) The set S may also be described as the least subset of N closed under certainrules. Describe the rules. Write down a principle of rule induction appropriatefor the set S. [4 marks](b) Show by rule induction that hcf (I) divides n for every n ? S. [3 marks](c) Let n ? S. Establish thatif p.h < n then (n ? p.h) ? Sfor all non-negative integers p. [5 marks](d) Show that h divides n for every n ? S. [Hint: suppose otherwise and derive acontradiction.] [5 marks](e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).[3 marks]5 (TURN OVER)CST.2008.2.6SECTION C5 Probability(a) Suppose that X is a random variable whose value r is distributed Geometric(p).Write down the expression for the probability P(X = r). [3 marks](b) By using a suitable generating function or otherwise, show that the expectationE(X) = (1 ? p)/p. [5 marks]The University Computing Service defifine a serious power outage as a power cut thatlasts for longer than their Uninterruptable Power Supply equipment can maintainpower. During the course of an academical year the number of serious power outagesis a random variable whose value is distributed Geometric(2/5). Accordingly, theprobability of having no serious power outages during the course of a year is 2/5.(c) The University is investigating a compensation scheme which would make nopayment over the year if the number of serious power outages were zero orone but which would pay the Computing Service £1000 for every such outage(including the fifirst) if the total number of serious power outages in a year weretwo or more. Determine the expected annual sum that the Computing Servicewould receive. [8 marks](d) To what value would the parameter of the Geometric Distribution have to bechanged (from 2/5) for the expected annual sum to be £750? [4 marks]6 Probability(a) Give a brief account of the Trinomial Distribution and include in yourexplanation an expression that is equivalent to n!r!(n?r)! prqn?r for the BinomialDistribution. [5 marks](b) An indicator light can be in one of three states: OFF, FLASHING and ON, withprobabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lightswhose states are mutually independent.(i) What is the probability that all fifive lights are OFF? [3 marks](ii) What is the probability that three lights are OFF, one light is FLASHINGand one light is ON? [3 marks](iii) What is the probability that three or more lights are OFF and at most oneis ON? [9 marks]All results must be expressed as fractions.6CST.2008.2.7SECTION D7 Software DesignSoftware systems often incorporate structural representations of the applicationdomain in which they operate. For example, a vehicle control system should beaware of the fact that the car has precisely four wheels. This kind of informationmust be captured, encoded and tested at each stage of the software design process.Using the number of wheels in a car as a simple example, describe relevant designactivities and products at each of the following phases of a software project:(a) inception; [4 marks](b) elaboration; [4 marks](c) construction; [4 marks](d) transition; [4 marks](e) system operation. [4 marks]8 Regular Languages and Finite Automata(a) Explain what is a context-free grammar and the language it generates.[4 marks](b) What does it mean for a context-free grammar to be regular? Given anydeterministic fifinite automaton M, describe a regular context-free grammarthat generates the language of strings accepted by M. [4 marks](c) Construct a non-deterministic fifinite automaton with ?-transitions whoselanguage of accepted strings is equal to the language over the alphabet {a, b, c}generated by the context-free grammar with non-terminals q0 and q1, whosestart symbol is q0 and whose productions are q0 ? abq1, q1 ? ?, q1 ? q0 andq1 ? abc. [4 marks](d) Is every language generated by a context-free grammar equal to theset of strings accepted by some non-deterministic fifinite automaton with?-transitions? Justify your answer. (Any standard results about regularlanguages you use should be carefully stated, but need not be proved.)[8 marks]7 (TURN OVER)CST.2008.2.89 Professional Practice and Ethics(a) The British Computer Society Code of Conduct has four sections. What kindof professional conduct does each section cover, and how does each of thesekinds of conduct benefifit the profession and its members? [8 marks](b) True or False questions:(i) A User can provide occasional use of the University computer system fora friend who is a temporary visitor.(ii) Circumstances that mitigate minor infractions of the rules promulgatedby the Information Technology Syndicate include, among other things,inebriation.(iii) Appropriate use of the Cambridge University Data Network (CUDN)means bona fifide academic activity plus a low level for private purposes.(iv) Small amounts of commercial activity are acceptable as long as the Useris acting in a private capacity.[4 marks](c) The IT industry is increasingly aware of its own environmental impact.Describe at least one environmental problem to which the industry contributesand how, as an IT professional, you can help to solve this problem. [4 marks](d) "Social engineering is a greater threat to computer security than computercracking software." What is social engineering and what measures can betaken to guard against it? [2 marks](e) What is copyleft and how is it used to protect free, open-source, software?(a) Write brief notes on polymorphism in ML, using lists and standard list functionssuch as @ (append) and map. [4 marks](b) Explain the meaning of the following declaration and describe the correspondingdata structure, including the role of polymorphism.datatype 'a se = Void | Unit of 'a | Join of 'a se * 'a se;[4 marks](c) Show that ML lists can be represented using this datatype by writing thefunctions encode_list of type 'a list -> ‘a se and decode_list of type’a se -> ‘a list, such that decode_list (encode_list xs) = xs for everylist xs. [3 marks](d) Consider the following function declaration:fun cute p Void = false| cute p (Unit x) = p x| cute p (Join(u,v)) = cute p u orelse cute p v;What does this function do, and what is its type? [4 marks](e) Consider the following expression:fn p => cute (cute p)What does it mean, and what is its type? Justify your answer carefully.[5 marks]2CST.2014.1.32Foundations of Computer Science(a) Write brief notes on the queue data structure and how it can be implementedeffiffifficiently in ML. In a precise sense, what is the cost of the main queueoperations? (It is not required to present ML code.) [6 marks](b) Run-length encoding is a way of compressing a list in which certain elementsare repeated many times in a row. For example, a list of the form [a, a, a, b, a, a]is encoded as [(3, a),(1, b),(2, a)]. Write a polymorphic function rl_encode toperform this encoding. What is the type of rl_encode? [6 marks](c) The simple task of testing whether two lists are equal can be generalised to allowa certain number of errors. We consider three forms of error:• element mismatch, as in [1,2,3] versus [1,9,3] or [1,2,3] versus [0,2,3]• left deletion, as in [1,3] versus [1,2,3] or [1,2] versus [1,2,3]• right deletion, as in [1,2,3] versus [1,3] or [1,2,3] versus [1,2]Write a function genEquals n xs ys that returns true if the two lists xs andys are equal with no more than n errors, and otherwise false. You may assumethat n is a non-negative integer. [8 marks]All ML code must be explained clearly and should be free of needless complexity.3 (TURN OVER)CST.2014.1.4SECTION B3Object-Oriented Programming(a) (i) Explain the purpose of access modififiers in OOP languages. [2 marks](ii) Copy and complete the table below to show the access restrictions for thefour access modififiers in Java. [2 marks]Access ModififierDefifining classClass in same packageSubclass in difffferent packageNon-subclass in difffferent package(b) A Java game designer wishes to store all the game preferences (e.g., player name,screen size, music volume, etc.) within a custom Preference class.(i) Assuming each preference is stored as a unique String key mapping toa String value, give a simple implementation of Preference that allowsfor effiffifficiently setting or updating preferences and retrieving previously setones. Your implementation should defifine an exception that is thrown whena preference key is requested but not present. [5 marks](ii) It is important that only one Preference object exists in a running game.Show how to apply access modififiers and the Singleton design pattern toensure this. Your implementation should lazily instantiate the object. Is itnecessary to make your class final or Cloneable? Explain your answer.[6 marks](c) The designer also implements other Singleton classes in the game and proposesto create a SingletonBase base class from which all such classes would inheritthe singleton behaviour. By providing example Java code, explain why this isnot viable. [5 marks]4CST.2014.1.54Object-Oriented ProgrammingA Lecturer wishes to create a program that lists his students sorted by the numberof practical assignments they have completed. The listing should be greatest numberof assignments fifirst, sub-sorted by name in lexicographical order (A to Z).A class StudentInfo stores the name and number of assignments completed for astudent. Amongst other methods, it contains a void setCompleted(int n) methodthat allows changes to the number of completed assignments.(a) Provide a defifinition of StudentInfo with an equals() method and a naturalordering that matches the given requirement. [9 marks](b) A TreeSet is used to maintain the StudentInfo objects in appropriate order.When setCompleted(…) is called on a StudentInfo object it is necessaryto remove the object from the set, change the value and then reinsert it toensure the correct ordering. This is to be automated by applying the Observerdesign pattern via classes UpdatableTreeSet and SubscribableStudentInfo.A partial defifinition of UpdatableTreeSet is provided below.public class UpdatableTreeSet extendsTreeSet {// To be called just before the StudentInfo object is updatedpublic void beforeUpdate(SubscribableStudentInfo s) {remove(s);}// To be called just after the StudentInfo object is updatedpublic void afterUpdate(SubscribableStudentInfo s) {add(s);}}(i) Extend StudentInfo to create SubscribableStudentInfo such that: multiple UpdatableTreeSet objects can subscribe and unsubscribe to receiveupdates from it; and the beforeUpdate(…) and afterUpdate(…)methods are called appropriately on the subscribed UpdatableTreeSetobjects whenever setCompleted(…) is called. [6 marks](ii) Give a complete defifinition of UpdatableTreeSet that overrides the inherited methods boolean add(SubscribableStudentInfo) and booleanremove(Object) to automatically subscribe and unsubscribe to theirarguments, as appropriate. You may ignore all other methods inheritedfrom TreeSet. [5 marks]5 (TURN OVER)CST.2014.1.6SECTION C5Numerical Methods(a) Floating point representation:(i) If a single-precision flfloating point number is added to a double-precisionflfloating point number, what can we say about the expected and worst-caserepresentation errors in the result? [2 marks](b) Floating point rounding:(i) Would a round-to-odd rule introduce a difffferent amount of bias comparedwith the normally used round-to-even rule? [2 marks](ii) What is it about counting in base 10 that causes bias in the standardapproach used when rounding to a given number of signifificant fifigures?Explain whether a similar rule for numbers expressed in base 4 wouldintroduce a bias. [4 marks](c) Matrix multiplication conditioning:(i) When a pair of matrices of dimension N × N are multiplied, what is theexpected and worst case representation error in the result? [2 marks](ii) Before using Gaussian Elimination to achieve triangle form when solvinga system of simultaneous equations, what step or steps can be taken toensure numerical stability? [4 marks](iii) What is meant by backwards stability regarding a numerical method?[2 marks](iv) What role can partial derivatives play in examining the stability of acomputation compared with using a condition number? [4 marks]6CST.2014.1.76Numerical Methods(a) A lander for the planet Mars has initial mass M0 = m(0) kilograms whichincludes F0 = f(0) kilograms of fuel. It is released from an orbiter at time zeroat height H0 = h(0) with an initial downwards velocity of zero. It must touchdown at less than 1 metre per second. Its downward force is Mg (where g isconstant) and this is countered by a rocket motor that is pre-programmed togenerate a time-varying upwards force of u(t). The motor burns fuel at a massrate proportional to the force it develops. This is summarised in these equations:dm(t)dt= ??u(t)dv(t)dt=u(t) ? gm(t)m(t)dh(t)dt= v(t)A discrete-time computer simulation of the landing uses time steps ?t. Using aprogramming language of your choice or pseudo code:(i) Give a suitable state vector for the system. Include setup code that suitablyinitialises the state vector. [1 mark](ii) Give state update assignments for one time step based on simple linearprojections assuming a function u(t) has been provided. [2 marks](iii) Give code for the various stopping conditions. These include a safe landing,a fatal crash or running out of fuel. [1 mark](iv) Why does a simple linear projection lead to a velocity modelling errorin every time step. What determines the error magnitude and does itcompound over successive steps? [3 marks](b) (i) Brieflfly describe the bisection method (binary chop) for fifinding a root of anequation. Mention two possible stopping conditions. [3 marks](ii) Recall that the CORDIC algorithm uses successive approximation wherethe ith division of the interval is by arctan(2?i ). Give a stopping conditionfor CORDIC. [2 marks](iii) The following approximation can be used for cosine: cos(x) ? 1 ? x22. Doesit accurately deliver three signifificant decimal digits where the argumentrange is 0.0 to ?/4 ? [2 marks](iv) Approximately how many iterations of CORDIC are required to ensure threesignifificant decimal digits are accurate over the same range? [6 marks]7 (TURN OVER)CST.2014.1.8SECTION D7Algorithms(a) Consider the radix sort algorithm.(i) Explain how radix sort works, to what inputs it can be applied and whatits asymptotic complexity is. [5 marks](ii) Explain why running radix sort does not proceed from most to leastsignifificant digit, as would at fifirst seem more intuitive. [4 marks](iii) Give a proof by induction of the correctness of radix sort. [4 marks](b) Clearly describe an algorithm, strictly better than O(n2 ), that takes a positiveinteger s and a set A of n positive integers and returns a Boolean answer to thequestion whether there exist two distinct elements of A whose sum is exactly s.Evaluate its complexity. [7 marks]8CST.2014.1.98Algorithms(a) Explain an effiffifficient method to fifind the k-th smallest number in a set of nnumbers (output: one number), without fifirst sorting the n numbers, and discussits complexity in terms of n and k. [4 marks](b) Explain an effiffifficient method to fifind the k smallest numbers in a set of n numbers(output: k numbers), without fifirst sorting the n numbers, and discuss itscomplexity in terms of n and k. How much extra work is needed comparedto (a)? [4 marks](c) Draw four distinct binary search trees (BSTs) for the following set of keys:{1, 2, 3, 4}. [2 marks](d) Let a height-balanced BST (hBST) be a BST with the additional defifininginvariant that each node is the parent of subtrees whose heights diffffer by atmost 1. Give an effiffifficient procedure to insert into an hBST and prove that thedefifining invariant is preserved. [10 marks]9 (TURN OVER)CST.2014.1.109Algorithms(a) Explain the terms amortized analysis, aggregate analysis and potential method.[6 marks](b) Consider an arbitrary sequence of n stack operations PUSH(), POP() andMULTIPOP(x) in which POP() or MULTIPOP(x) never attempt to remove moreelements than there are on the stack. Assuming that the stack begins withs0 items and fifinishes with sn items, determine the worst-case total cost forexecuting the n operations as a function of n, s0 and sn. You may assumePUSH() and POP() cost 1 each and MULTIPOP(x) costs x. [5 marks](c) Suppose we want to store a number of items in an array, but we do not know inadvance how many items need to be stored. The INSERT(x) operation appendsan item x to the array. More precisely, if the size of the array is large enough, xis inserted directly at the end of the array. Otherwise, a new array of larger sizeis created that contains all previous items with x being appended at the end.The total cost of INSERT(x) is 1 in the fifirst case, and the size of the new arrayin the second case.(i) Devise a strategy which, for any integer n, performs any sequence of nINSERT(.) operations at a total cost of O(n). [5 marks](ii) For the strategy described in (c)(i), give a proof of the cost of the algorithmusing the potential method. [4 marks]10CST.2014.1.1110Algorithms(a) Given any directed graph G = (V, E) with non-negative edge weights, considerthe problem of all-pairs shortest path (APSP). Give the asymptotic runtimes ofthe following four algorithms when applied (directly or iterated) to the APSPproblem as a function of |V | and |E|, and provide a brief justifification for youranswer: Bellman-Ford, Dijkstra, matrix multiplication and Johnson. [8 marks](b) Consider the problem of converting currencies modelled by a directed graphG = (V, E) with |V | vertices representing currencies and |E| directed edges(u, v) each of which has a strictly positive weight w(u, v) > 0 representingthe exchange rate. For instance, for any real number x, we have x USD =w(dollars, pounds) · x GBP. Our goal is, given a pair of currencies s, t ? V , tofifind the least expensive way of exchanging from s to t, possibly by using morethan one exchange.(i) How could you transform the graph by reweighting the edges so that theproblem could be solved with a shortest path algorithm? Indicate whichshortest path algorithm is used. [8 marks](ii) How would you deal with negative-weight cycles if they occurred in thetransformed graph? Give the perspective of the currency trader as well asthat of a computer scientist.(a) Brieflfly explain the difffferences between combinational and sequential logic.[2 marks](b) With the aid of appropriate diagrams, brieflfly explain the operation of Mooreand Mealy fifinite state machines and highlight their difffferences. [6 marks](c) The state sequence for a binary counter is as follows: The counter is to be implemented using four synchronously clocked D-typeflflip-flflops.(i) Draw a state table for the counter, showing the required D inputs.[4 marks](ii) Find expressions for the D inputs, making use of unused states ifappropriate. [6 marks](iii) What problem could occur when the counter circuit is powered-up? Givetwo possible general methods for overcoming the problem. [2 marks]2CST.2008.2.32 Digital Electronics(a) With the aid of relevant diagrams, show the effffect on the output of acombinational logic circuit of a:(i) static hazard;(ii) dynamic hazard. [3 marks](b) Simplify the following expressions using Boolean algebra:(i) X = (A + B + A . B).(A + B). A . B(ii) Y = (A + B + A . B). C[4 marks](c) Given:F = A . B . C . D + A . C + B . C . D + B . C + A . C . D + A . B . C . D(i) Show using a Karnaugh map that F can be simplifified toF1 = A . B + A . B + A . C + B . C . D[2 marks](ii) Show that there are a total of four possible expressions for F. [3 marks](iii) Show how F1 can be implemented using NAND gates and draw the circuitdiagram. Assume that complemented input variables are available.[2 marks](iv) Show how the static 1 hazard in F1 can be eliminated using a Karnaughmap-based approach. [2 marks](v) Now implement F1 assuming that only 2-input NAND gates are available.[4 marks]3 (TURN OVER)CST.2008.2.4SECTION B3 Discrete MathematicsLet X and Y be sets. You are reminded that a relation from X to Y is a subset ofthe product X × Y .(a) Explain what it means for a relation f from X to Y to be a function, aninjection and a surjection from X to Y . [4 marks](b) A bijection from X to Y is defifined to be a function from X to Y which isboth an injection and a surjection. Prove that a function f from X to Y is abijection iffff it has an inverse function g, i.e. g is a function from Y to X suchthat g ? f = idX and f ? g = idY .[Remember to prove both the “if” and “only if” parts of the assertion.][12 marks](c) Describe, without proof, a bijection from P(X × Y ) to (X ? P(Y )) and itsinverse. [4 marks]4CST.2008.2.54 Discrete MathematicsLet I be a non-empty subset of the natural numbers N = {1, 2, 3, · · ·}.The set S is defifined to be least subset of N such thatI ? S, andif m, n ? S and m < n, then (n ? m) ? S.Defifine h to be the least member of S. This question guides you through to a proofthat h coincides with the highest common factor of I, written hcf (I), and defifinedto be the natural number with the properties thathcf (I) divides n for every element n ? I, andif k is a natural number which divides n for every n ? I, then kdivides hcf (I).[Throughout this question you may assume elementary facts about division.](a) The set S may also be described as the least subset of N closed under certainrules. Describe the rules. Write down a principle of rule induction appropriatefor the set S. [4 marks](b) Show by rule induction that hcf (I) divides n for every n ? S. [3 marks](c) Let n ? S. Establish thatif p.h < n then (n ? p.h) ? Sfor all non-negative integers p. [5 marks](d) Show that h divides n for every n ? S. [Hint: suppose otherwise and derive acontradiction.] [5 marks](e) Explain very brieflfly why the results of parts (b) and (d) imply that h = hcf (I).[3 marks]5 (TURN OVER)CST.2008.2.6SECTION C5 Probability(a) Suppose that X is a random variable whose value r is distributed Geometric(p).Write down the expression for the probability P(X = r). [3 marks](b) By using a suitable generating function or otherwise, show that the expectationE(X) = (1 ? p)/p. [5 marks]The University Computing Service defifine a serious power outage as a power cut thatlasts for longer than their Uninterruptable Power Supply equipment can maintainpower. During the course of an academical year the number of serious power outagesis a random variable whose value is distributed Geometric(2/5). Accordingly, theprobability of having no serious power outages during the course of a year is 2/5.(c) The University is investigating a compensation scheme which would make nopayment over the year if the number of serious power outages were zero orone but which would pay the Computing Service £1000 for every such outage(including the fifirst) if the total number of serious power outages in a year weretwo or more. Determine the expected annual sum that the Computing Servicewould receive. [8 marks](d) To what value would the parameter of the Geometric Distribution have to bechanged (from 2/5) for the expected annual sum to be £750? [4 marks]6 Probability(a) Give a brief account of the Trinomial Distribution and include in yourexplanation an expression that is equivalent to n!r!(n?r)! prqn?r for the BinomialDistribution. [5 marks](b) An indicator light can be in one of three states: OFF, FLASHING and ON, withprobabilities 1/2, 2/5 and 1/10 respectively. A test panel has fifive such lightswhose states are mutually independent.(i) What is the probability that all fifive lights are OFF? [3 marks](ii) What is the probability that three lights are OFF, one light is FLASHINGand one light is ON? [3 marks](iii) What is the probability that three or more lights are OFF and at most oneis ON? [9 marks]All results must be expressed as fractions.6CST.2008.2.7SECTION D7 Software DesignSoftware systems often incorporate structural representations of the applicationdomain in which they operate. For example, a vehicle control system should beaware of the fact that the car has precisely four wheels. This kind of informationmust be captured, encoded and tested at each stage of the software design process.Using the number of wheels in a car as a simple example, describe relevant designactivities and products at each of the following phases of a software project:(a) inception; [4 marks](b) elaboration; [4 marks](c) construction; [4 marks](d) transition; [4 marks](e) system operation. [4 marks]8 Regular Languages and Finite Automata(a) Explain what is a context-free grammar and the language it generates.[4 marks](b) What does it mean for a context-free grammar to be regular? Given anydeterministic fifinite automaton M, describe a regular context-free grammarthat generates the language of strings accepted by M. [4 marks](c) Construct a non-deterministic fifinite automaton with ?-transitions whoselanguage of accepted strings is equal to the language over the alphabet {a, b, c}generated by the context-free grammar with non-terminals q0 and q1, whosestart symbol is q0 and whose productions are q0 ? abq1, q1 ? ?, q1 ? q0 andq1 ? abc. [4 marks](d) Is every language generated by a context-free grammar equal to theset of strings accepted by some non-deterministic fifinite automaton with?-transitions? Justify your answer. (Any standard results about regularlanguages you use should be carefully stated, but need not be proved.)[8 marks]7 (TURN OVER)CST.2008.2.89 Professional Practice and Ethics(a) The British Computer Society Code of Conduct has four sections. What kindof professional conduct does each section cover, and how does each of thesekinds of conduct benefifit the profession and its members? [8 marks](b) True or False questions:(i) A User can provide occasional use of the University computer system fora friend who is a temporary visitor.(ii) Circumstances that mitigate minor infractions of the rules promulgatedby the Information Technology Syndicate include, among other things,inebriation.(iii) Appropriate use of the Cambridge University Data Network (CUDN)means bona fifide academic activity plus a low level for private purposes.(iv) Small amounts of commercial activity are acceptable as long as the Useris acting in a private capacity.[4 marks](c) The IT industry is increasingly aware of its own environmental impact.Describe at least one environmental problem to which the industry contributesand how, as an IT professional, you can help to solve this problem. [4 marks](d) "Social engineering is a greater threat to computer security than computercracking software." What is social engineering and what measures can betaken to guard against it? [2 marks](e) What is copyleft and how is it used to protect free, open-source, software? 1. (50 pts) Write a C or C+* program A6p1.c(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string (CA"Z, 'B°Y, 'C'X, etc). You should divide this conversion task among the n threads as evenly as possible, Print out the string both before and after conversion on two separatelines. Hint: it is dangerous to have printing code in your thread function ($). You may refer to testThread.s test Thread2.c, pthread ex1.c, pthread ex2.c for examples. Note: if you do not use pthread to divide the conversion task among the threads, you may get zero points. #include #include #include void proc(void *arg) printf("'arg=ldn", (long)arg);: pthread exit(void )99)//if we have this function call, the main will print out "result-99" instead of "result=2016" return (void ) 2016; int main) int r pthread_t x void "result; I/when pthread creste and pthread join successfully execute, they will return rapthread_create (8x, NULL proc, Tvoid ")34); assert(r0); r=pthread join (x, &result); assert(; printfí"result=ldn", (long) result ); return; #include #include #indlude void sproctvoid sarg) t int i; forf-0ikindly answer all the questionsComputer ScienceEngineering & TechnologyC++ ProgrammingCOM 123Share Question