Reference no: EM133441951
Question: Software design is an important process in software development lifecycle. However, a lot of software developer/house tends to ignore the process. Therefore, provide and explain 2 motivations on software design
What is a principal type scheme? Give the principal type scheme for N1, or explain informally why it does not have one.
Organize your work in a table with appropriately labeled a columns. Show the aligned sequences. Pseudo code for findLCS() appears after the pseudo code for cutRod(). int cutRod( int [] p ) Initialize. Set n to the length of the prices array p. Allocate space for an array r from 0 ton Set r[ o ] to 0 Loop for j from 1 to n inclusive Set q to -o0 for i from 1 toj inclusive if p[i] + r[ j - i] >q Set q to p[i] + r[j - i] set r[j ] to a Return r[n] int [][][] findLCS( sequence X, sequence Y) Initialize. Set m to the length of X and n to the length of Y. Declare two 2D arrays of size m+1 by n+1 named c and b. Loop for i from 1 to m inclusive forj from 1 to n inclusive if x[i] equals y[j] cli,j) = 1 + cli - 1, j - 1) bli, j) = NW else if cli - 1,j) = cli, j - 1) cli, j) = cli - 1,j) bli, j) = N else cli, j) = cli, j - 1) bli, j) = W Return the 2D arrays.What is the principal difference between a CAM and a RAM? [4 marks] (b) What is the difference between fully associative, set associative and direct mapped lookup? [6 marks] (c) Why are TLBs always much smaller than caches?
(d) Which of the lookup mechanisms in part (b) is usually used for a TLB and why aren't the other mechanisms usually used? 2 ECAD Consider the following mysterious Verilog module. module mystery(q,wr,a,s); input c,r,a; output [0] s; reg [2:0] s; always @(posedge c or posedge r) if(r) s<=01; else begin if(a && (s<17)) s<=s+1; else if(!a && (s>0)) s<=s-1; end endmodule
(a) How many flip-flops will be required to implement the mystery module, and how will signals c and r be connected to these flip-flops?
(b) What is the state transition diagram for this mystery module?
(c) If this module were synthesised to the minimum sum of products form, what would the equations be for next state bits s[0], s[1] and s[2]? 2 CST.2004.3.3 3 Data Structures and Algorithms.
Publication* getPub(int libRef) method, Which of the lookup mechanisms in part (b) is usually used for a TLB and why aren't the other mechanisms usually used? [6 marks] 2 ECAD Consider the following mysterious Verilog module. module mystery(c,r,a,s); input c,r,a; output [2:0] s; reg [2:0] s; always @(posedge c or posedge r) if(r) s<=0; else begin if(a && (s<7)) s<=s+1; else if(!a && (s>0)) s<=s-1; end endmodule (a) How many flip-flops will be required to implement the mystery module, and how will signals c and r be connected to these flip-flops? [5 marks] (b) What is the state transition diagram for this mystery module?
(c) If this module were synthesised to the minimum sum of products form, what would the equations be for next state bits s[0], s[1] and s[2]?
(b) Consider the use of a monad for input-output. For the purposes of this question, take the IO monad as including two operations readint and writeint which respectively read integers from stdin and write integers to stdout. Give the types of these operators.
(c) Assume MLreadint and MLwriteint are primitives with side effects for inputoutput and consider the ML expression add1 of type int: let val x = MLreadint() in MLwriteint(x+1); x end (i) Give an equivalent expression which uses the IO monad instead of side-effects, and state its type.
(ii) Give a function run2diff which can be applied to your answer to part (c)(i). When so applied it should give a value in the IO monad which corresponds to ML code that runs add1 twice and returns the difference between the values read. [4 marks] 2 CST.20204.3.3 3 Data Structures and Algorithms
(a) Describe how the Lempel Ziv text compression algorithm works, illustrating your answer by deriving the sequence of numbers and corresponding bit patterns it would generate when applied to a string starting with the following 24 characters: ABCDABCDABCDABCDABCDABCD ...
You may assume that the initial table is of size 256 (containing bytes 0 to 255) and that the codes for "A", "B", "C" and "D" are 65, 66, 67 and 68, respectively.
(b) Estimate how many bits the algorithm would use to encode a string consisting of 1000 repetitions of the character "A".
(d) a method to return the address of a Publication oabject in the PPA that has the library reference number matching the "libRef" argument. 4 Comparative Programming Languages
(a) Discuss to what extent a programmer can expect a program that conforms to a standard to generate identical results when run under different conforming compilers on different machines.
(b) ALGOL 60 provided call by value and call by name, Pascal provided call by value and call by reference, and ALGOL-W provided a variety of calling methods including call by result and call by value-result.