Top 80+ Solved Theory of Computation and Compiler Design MCQ Questions Answer

From 61 to 74 of 74

Q. A canonical set of items is given belowS --> L. > RQ --> R.On input symbol < the set has

a. a shift-reduce conflict and a reduce-reduce conflict.

b. a shift-reduce conflict but not a reduce-reduce conflict.

c. a reduce-reduce conflict but not a shift-reduce conflict.

d. neither a shift-reduce nor a reduce-reduce conflict.

  • d. neither a shift-reduce nor a reduce-reduce conflict.

Q. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is:

a. n1 is necessarily less than n2

b. n1 is necessarily equal to n2

c. n1 is necessarily greater than n2

d. none of these

  • b. n1 is necessarily equal to n2

Q. Which of the following is essential for converting an infix expression to the postfix from efficiently?

a. An operator stack

b. An operand stack

c. An operand stack and an operator stack

d. A parse tree

  • a. An operator stack

Q. Which is True about SR and RR-conflict:

a. If there is no SR-conflict in CLR(1) then definitely there will be no SR-conflict in LALR(1).

b. RR-conflict might occur if lookahead for final items(reduce-moves) is same.

c. Known that CLR(1) has no RR-conflict, still RR-conflict might occur in LALR(1).

d. All of the above.

  • d. All of the above.

Q. Shift-Reduce parsers perform the following:

a. Shift step that advances in the input stream by K(K > 1) symbols and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol.

b. Shift step that advances in the input stream by one symbol and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol.

c. Shift step that advances in the input stream by K(K = 2) symbols and Reduce step that applies a completed grammar rule to form a single tree

d. Shift step that does not advance in the input stream and Reduce step that applies a completed grammar rule to form a single tree.

  • b. Shift step that advances in the input stream by one symbol and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol.

Q. Incremental-Compiler is a compiler

a. which is written in a language that is different from the source language

b. compiles the whole source code to generate object code afresh

c. compiles only those portion of source code that have been modified.

d. that runs on one machine but produces object code for another machine

  • c. compiles only those portion of source code that have been modified.

Q. Consider the following C code segment.for (i = 0, i<n; i++){ for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } }}Which one of the following is false?

a. The code contains loop invariant computation

b. There is scope of common sub-expression elimination in this code

c. There is scope of strength reduction in this code

d. There is scope of dead code elimination in this code

  • d. There is scope of dead code elimination in this code

Q. A linker reads four modules whose lengths are 200, 800, 600 and 500 words respectively. If they are loaded in that order, what are the relocation constants?

a. 0, 200, 500, 600

b. 0, 200, 1000, 1600

c. 200, 500, 600, 800

d. 200, 700, 1300, 2100

  • b. 0, 200, 1000, 1600

Q. A language L allows declaration of arrays whose sizes are not known during compilation. It is required to make efficient use of memory. Which of the following is true?

a. A compiler using static memory allocation can be written for L

b. A compiler cannot be written for L, an interpreter must be used

c. A compiler using dynamic memory allocation can be written for L

d. None of the above

  • c. A compiler using dynamic memory allocation can be written for L

Q. Consider the following expressionu*v+a-b*c Which one of the following corresponds to a static single assignment from the above expressions

a. x1 = a - b y1 = p * c x2 = u * v y2 = p + q

b. x 1 = a - b y1 = x2 * c x3 = u * v y2 = x4 + y3

c. x1 = a - b y2 = x1 * c x2 = u * v y3 = x2 + y2

d. p = a - b q = p * c p = u * v q = p + q

  • c. x1 = a - b y2 = x1 * c x2 = u * v y3 = x2 + y2
Subscribe Now

Get All Updates & News