Define class Expr twice: once using a linked list of nodes as the…

Question Answered step-by-step Define class Expr twice: once using a linked list of nodes as the… Define class Expr twice: once using a linked list of nodes as the representation and onceusing a character string as the representation. Experiment with different ways of printingthe expression: fully parenthesized, postfix notation, assembly code, etc.[10] ( ∗2) Define a class Char_queue so that the public interface does not depend on the representa-tion. Implement Char_queue (a) as a linked list and (b) as a vector. Do not worry about con-currency.[11] ( ∗3) Design a symbol table class and a symbol table entry class for some language. Have alook at a compiler for that language to see what the symbol table really looks like.[12] ( ∗2) Modify the expression class from §X.17[11] to handle variables and the assignmentoperator =. Use the symbol table class from §X.17[11].Implement the functions of the ”cannonical complete class” X from §17.1 to do notingbut print out their name and the address of their object (and of their argument where applica-ble). Now test X by defining variables, members, objects on the free store, passing argu-ments, etc.Define a one-way function. [4 marks](b) Explain why the existence of one-way functions would imply that P6=NP. [7 marks](c) Recall that Reach is the problem of deciding, given a graph G a source vertex s and a target vertex t, whether G contains a path from s to t; and Sat is the problem of deciding whether a given Boolean formula is satisfiable.For each of the following statements, state whether it is true or false and justify your answer.(i) If Reach is NP-complete then P=NP. [3 marks](ii) If Reach is NP-complete then NP6=PSPACE. [3 marks] (iii) If Sat is PSPACE-complete then NP=PSPACE. [3 marks](a) Define strong and weak consistency. [2 marks](b) A process group manages a set of widely distributed replicas. The group is open and unstructured; that is, external processes may invoke any group member for reading or writing.(i) Discuss how the replicas can be kept strongly consistent in the presence of concurrent invocations and failures. [12 marks](ii) Would it be more appropriate to use a structured group (with a single co-ordinator) to manage the replicas? Justify your answer. [6 marks]Your solution should discuss the selection and use of algorithms and protocols. It is not necessary to specify them in great detail.(a) We wish to produce two algorithms: one which draws the outline of a circle and one which draws a filled circle.(i) Describe an efficient algorithm which will draw a one-pixel wide outline of a circle of integer radius, R, centred on the origin. [10 marks](ii) Describe the modifications required to your algorithm to make it draw a filled circle. [3 marks](b) Given a function drawline(x1,y1,x2,y2), describe an algorithm for drawing a Bezier cubic curve to a specified level of accuracy using only straight lines. [7 marks]You have been provided with the description of a programming language, J, intended for scripting applications. Its syntax is similar to a cut-down version of Java in that it consists of function definitions which have bodies containing if-then-else, while-do, assignments and (typed) declarations of variables. Only one statement or keyword may occur on a line so that it is sufficient to describe the start of a loop iteration with its line number. You need to explain to your boss the alternatives for implementing this so that a decision may be made as to the best implementation strategy.The choice is between:(a) compiling J to machine code;(b) compiling J to “interpreted byte code”, and then interpreting this;(c) parsing J to a syntax tree representation and then interpreting this using a function which walks the tree;(d) keeping J in a text file and then interpreting it by reading each line (and acting on it) as and when the line is required.For each of (a)-(d), (i) summarise the main phases of work that are done before execution in each case, giving a brief explanation of the main actions of the main interpreter loop (if any) during execution, and (ii) for each of the following possible erroneous forms, explain whether the error would be found before or during execution: malformed syntax, undeclared variable, type error, division by zero. [5 marks each][2] ( ∗2) Define a resource handle, a ”smart pointer” that holds a pointer to an object on the freestore passed as an argument to a constructor. ”Forget” to define copy operations. Now testthe handle by defining variables, members, objects on the free store, passing arguments, etc.,and see where leaks occur.[3] ( ∗1.5) When do you need a constructor? When do memberwise construction suffice? Whenis memberwise construction preferable?[4] ( ∗1) Design, implement and test a Vector class with an initializer-list constructor and no con-structor that takes a integer as a size. Instead, give it a constructo that takes a Count type, sothat you can’t get ambiguities between and integer number of elements and an integer ele-ment value.[5] ( ∗3) Write an extremely simple document editor with only three commands: ”Insert a stringas line number n,” ”delete line n,” and ”undo the last (non-undo) operation.” In addition,provide a cursor to a character in the document (or one beyond the last character) that can bemoved forwards and backwards. Do not let any command lead to an invalid cursor. Hint:§17.5.1.3.[6] ( ∗3) Implement a simple Matrix along the lines of the one in §17.5.2. Measure the perfor-mance of an addition of 1000-by-1000 matrices with and without m ove operations. If youdid not have the option of adding move operations, C Computer Science Engineering & Technology C++ Programming Y 123445 Share QuestionEmailCopy link Comments (0)