A rooted directed graph has vertices identified by integers. Each…

Question Answered step-by-step A rooted directed graph has vertices identified by integers. Each… A rooted directed graph has vertices identified by integers. Each vertex v has a leftsuccessor given by left(v) and a right successor given by right(v), where leftand right are ML functions of type int->int. The graph contains the root andall vertices reachable by paths from the root.Define a datatype G that could be used to represent such a graph with given root,and left and right functions, and define a function mkgraph(root, left, right)that can create values of type G. Show that such values can be used to represent?both finite and infinite graphs. [4 marks]A path through the graph is represented by a bool list with true and falseindicating left and right edges, respectively.Define the function last : G -> bool list -> int that will yield, for a givengraph, the identity of the vertex reached by following the given path from the root.[3 marks]In a new application, where last is repeatedly called, it is required for it to returnboth the identity of the last vertex and a count of how often this particular vertexhas been returned. Define a new version of the datatype G, containing mutablevalues, that could be used. [3 marks]Illustrate the use of this datatype by defining the new versions of mkgraph andlast. [10 marks]4P3, 0 ? t ? 1Depict a calculation that draws the quadratic Be’zier bend, utilizing straightlines just, to inside a resilience ? . You might utilize the calculation from section (a)also, you might accept that you as of now have a calculation for drawing a straightline. [8 marks](c) Consider the control of detail in a bend that is addressed by an arrangement ofmany straight line sections. Portray how Douglas and P¨ucker’s calculationcan be utilized to eliminate unnecessary focuses. You might utilize the calculation fromsection (a).(a) Consider a straightforward irregular walk, Sn, characterized by S0 = an and Sn = Sn?1 + Xnfor n ? 1 where the arbitrary factors Xi (I = 1, 2, . . .) are autonomous andindistinguishably appropriated with P(Xi = 1) = p and P(Xi = ?1) = 1 ? p for someconsistent p with 0 ? p ? 1.(I) Find E(Sn) and Var (Sn) as far as a, n and p. [4 marks](ii) Use as far as possible hypothesis to infer an inexact articulationfor P(Sn > k) for huge n. You might leave your response communicated in wordingof the circulation work ?(x) = P(Z ? x) where Z is a normTypical arbitrary variable with zero mean and unit change. [6 marks](b) Consider the Gambler’s ruin issue characterized as to some degree (a) however with theexpansion of retaining boundaries at 0 and N where N is some sure number.Infer an articulation for the likelihood of ruin (that is, being assimilated at thezero hindrance) while beginning at position S0 = a for each a = 0, 1, . . . , N in thet25 Logic and Proof(a) State (with support) whether the accompanying recipe is satisfiable, substantial ornot one or the other. Note that an and b are constants.h?x [q(x) ? r(x)] ? ¬r(a) ? ?x [¬r(x) ? ¬q(a) ? p(x) ? q(x)]i? p(b) ? r(b)(b) Attempt to demonstrate the recipe [?x ?y R(x, y)] ? ?x ?z R(x, f(z)) by goal,with brief clarifications of each progression, including the change to condition structure.[4 marks](c) Give a model for the accompanying arrangement of provisos, or demonstrate that none exists.{¬R(x, y), ¬R(y, x)}{R(x, f(x))}{¬R(x, y), ¬R(y, z), R(x, z)}The Prolog predicate perm(+In,- Out) produces all stages of the information listIn. A software engineer executes perm/2 as follows:perm([],[]).perm(L,[H|T]) :- take(L,H,R), perm(R,T).The predicate take(+L,- E,- R) eliminates one component (E) from the information list L andbinds together R with the rest of L. Consequently, the rundown R has one component less than L.(a) Consider the perm/2 predicate:(I) Explain momentarily in words the activity of the perm/2 predicate.(ii) Provide an execution of the take/3 predicate.(iii) Give the total arrangement of replies (aligned correctly)by perm([1,2,3],A).(b) An understudy endeavors to conjure the inquiry perm(A,[1,2,3]).(I) Explain what occurs and why. [5 marks](ii) Implement a predicate sameLength/2 which is valid if the two boundariesare arrangements of a similar length.(iii) Using sameLength/2, etc., give an execution ofsafePerm/2 which produces stages no matter what the request inwhich the boundaries are given: both safePerm(+In,- Out) andsafePerm(- Out,+In) ought to produce all changes of In. The requestin which these changes are produced isn’t significant.Compose total program that utilizes the capacities recorded beneath. Aside from the printOdd work, primary ought to print the outcomes after each capacity call to a record.Compose work called productEven, that takes as its boundary an info document. The capacity ought to peruse two numbers and work out the complete result of just even numbers between them.Compose work in the C++called rundown that takes as its boundaries an info and result document. The capacity ought to peruse two numbers track down the amount of even numbers, the amount of odd numbers, and the total item between two qualities lower and upperHow do programming instruments change as frameworks scale? Examine this inquiryconcerning(a) a 2000-line gadget driver for a security basic sensor on board an airplane;(b) a 100,000-line motor control unit for a diesel motor that adjusts it for use intrucks, generators or water system siphons;(c) a million line long range interpersonal communication site like Facebook or MySpace;(d) a 50,000,000-line working framework.(a) A web server is an application that tunes in for approaching organization associationson TCP port 80. When an association is laid out, the undertaking of handlingclient demands and sending answers can be taken care of by an example of aLaborer class which you might expect as of now exists. Laborer carries out theImage transcription text1. This question is about lexing, parsing,and CFGs (= context free grammars).(a) For each of the followi… Show more… Show moreImage transcription text(b) In this question, we consider CFGs inwhich we take S to be the initial variable. Foreach of the following statemen… Show more… Show more  Computer Science Engineering & Technology Networking COMPUTER 254 Share QuestionEmailCopy link Comments (0)