(a) Write LISP program for detecting whether a LISP interpreter…
Question Answered step-by-step (a) Write LISP program for detecting whether a LISP interpreter… (a) Write LISP program for detecting whether a LISP interpreter treats thelanguage as being dynamically scoped (as was the case in historical LISP) or asbeing statically scoped (as is the case in modern LISP). You may use pseudo-codeand should explain your answer in detail. [4 marks] (b) You manage two junior programmers and overhear the following conversation:A: “I don’t know why anyone needs a language other than Java, itprovides clean thread-based parallel programming.”B: “Maybe, but I write my parallel programs in a functionalprogramming language because they are then embarrassingly parallel.”Discuss the correctness of these statements and the extent to which they coverthe range of languages for parallel programming. [6 marks](c) Explain why the SML interpreter accepts the declarationsdatatype ‘a FBtree = node of ‘a * ‘a FBtree list;fun dfs P (t: ‘a FBtree)= let exception Ok of ‘a;fun auxdfs( node(n,F) ) = if P n then raise Ok nelse foldl (fn(t,_) => auxdfs t) NONE F;in auxdfs t handle Ok n => SOME n end;while it does not accept the declarationexception Ok of ‘a; Write program to find the average of a given set of numbers. 2- Write program to find the smallest and the largest number from a given set of numbers. 3- Write program to count the number of 1using c programing write program to Find the maximum and the minimum elements for a set of n integers.: Write program that reads a set of integers and then finds and prints the sum of the even and odd integersThe commands C of a language for manipulating integer storage locations ` aregiven byC ::= skip | ` := E | C ; C | if B then C else C| while B do C | begin loc ` := E ; C endwhere B and E range over boolean and integer expressions respectively, whoseprecise syntax you do not need to specify, but which include various integer andboolean operations and an operation for reading the contents of a location. Thelast form of command is for block-structured local state.You may assume that evaluation of integer expressions E to integer values n has noside-effects on states s and that a suitable evaluation relation of the form E, s?n hasalready been defined; similarly an evaluation relation B, s?b for boolean expressionshas already been defined. Using these relations, give an operational semantics forcommands in the form of an inductively defined relation C, s ? sShow that there are syntactic ambiguities between (a) the minus (-) and exponentiation (**) operators, (b) the if-command and the if-then-elsecommand, and (c) the if-then-else-command and the repeatwhile-command. [4 marks] Define, in a programming language notation of your choice, a recursive descent parser that will construct the abstract syntax tree for an input stream conforming to the above syntax for commands. You may assume the existence of a function lex() that will yield an integer representing the next lexical token from the input stream, and the functions mk2(op,x), mk3(op,x,y) and mk4(op,x,y,z) that will construct abstract syntax tree nodes with a given operator and one, two or three operands. You should assume that exponentiation is right associative and more binding than subtraction which is left associative. The command following then should be the longest possible and the command before repeatwhile should be the shortest possible. [12 marks] Briefly outline how you would modify your parser if the command to the left of repeatwhile was changed to be the longest (rather than the shortest). [4 marks] 5 Data Structures and Algorithms You are given two sets of numbers Xi and Yj , where i and j run from 1 to N. Devise an algorithm to find the M largest values of Xi ?Yj . This algorithm should not be quadratic in N, though it is permitted to be quadratic in M. You should regard N as being of the order of 20,000 and M as being of the order of 1,000. (c) Describe an efficient algorithm to find the median of a set of 106integers whereit is known that there are fewer than 100 distinct integers in the set. [6 marks]6 Computer Design(a) Why does pipelining introduce data hazards? [4 marks](b) What mechanism may be used to remove some dards? [4 marks](c) Why is it not possible to remove all data hazards? [4 marks](d) What hardware is required to prevent data hazards from infringing theprogrammer’s model of instruction execution? [4 marks](e) What is the difference between a data hazard and a control hazard? [4 marks]5 [TURN OVERCST.2001.3.67 Operating System Functions(a) What are the key issues with scheduling for shared-memory multiprocessors?[3 marks](b) Processor affinity, take scheduling and gang scheduling are three techniquesused within multiprocessor operating systems.(i) Briefly describe the operation of each. [6 marks] Image transcription textLet A and B be two matrices of size n xn, where n is a power of 3. Theobjective is to compute th… Show more… Show more Computer Science Engineering & Technology Networking CMPE 272 Share QuestionEmailCopy link Comments (0)


