Top 80+ Solved Theory of Computation and Compiler Design MCQ Questions Answer
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.
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
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
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.
Q. Which of the following statement(s) regarding a linker software is/are true ? I A function of a linker is to combine several object modules into a single load module. II A function of a linker is to replace absolute references in an object module by symbolic references to locations in other modules.
a. Only I
b. Only II
c. Both I and II
d. Neither I nor II
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.
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
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
Q. Consider the intermediate code given below:1. i = 12. j = 13. t1 = 5 * i4. t2 = t1 + j5. t3 = 4 * t26. t4 = t37. a[t4] = –18. j = j + 19. if j <= 5 goto(3)10. i = i + 111. if i < 5 goto(2)The number of nodes and edges in the control-flow-graph constructed for the abovecode, respectively, are
a. 5 and 7
b. 6 and 7
c. 5 and 5
d. 7 and 8
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
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
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
Q. In multi-programmed systems, it is advantageous if some programs such as editors and compilers can be shared by several users. Which of the following must be true of multi-programmed systems in order that a single copy of a program can be shared by several users? I. The program is a macro II. The program is recursive III.The program is reentrant
a. I only
b. II only
c. Ill only
d. I, II and III