A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

41. A CFG G is given with the following productions where S is the start symbol, A is a non-terminal and a and b are terminals.

S→aS∣A
A→aAb∣bAa∣ϵ

For the correct answer in Q75, how many steps are required to derive the string and how many parse trees are there?
a. 6 and 1
b. 6 and 2
c. 7 and 2
d. 4 and 2
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).6 and 1

42. Some code optimizations are carried out on the intermediate code because
a. they enhance the portability of the compiler to other target processors
b. program analysis is more accurate on intermediate code than on machine code
c. the information from dataflow analysis cannot otherwise be used for optimization
d. the information from the front end cannot otherwise be used for optimization
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).they enhance the portability of the compiler to other target processors

43. Which one of the following is FALSE?
a. A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end
b. Available expression analysis can be used for common subexpression elimination
c. Live variable analysis can be used for dead code elimination
d. x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination

44. One of the purposes of using intermediate code in compilers is to
a. make parsing and semantic analysis simpler
b. improve error recovery and error reporting
c. increase the chances of reusing the machine-independent code optimizer in other compilers
d. improve the register allocation
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).increase the chances of reusing the machine-independent code optimizer in other compilers

45. Consider the grammar rule E → E1 - E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code
a. E1 should be evaluated first
b. E2 should be evaluated first
c. Evaluation of E1 and E2 should necessarily be interleaved
d. Order of evaluation of E1 and E2 is of no consequence
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).E2 should be evaluated first

46. Consider the intermediate code given below:

1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[t4] = –1
8. j = j + 1
9. if j <= 5 goto(3)
10. i = i + 1
11. if i < 5 goto(2)

The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
a. 5 and 7
b. 6 and 7
c. 5 and 5
d. 7 and 8
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).6 and 7

47. Consider the following code segment.

x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;

The minimum number of total variables required to convert the above code segment to static single assignment form is
a. 6
b. 8
c. 9
d. 10
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).10

48. Which of the following derivations does a top-down parser use while parsing an input string?
The input is assumed to be scanned in left to right order.
a. Leftmost derivation
b. Leftmost derivation traced out in reverse
c. Rightmost derivation
d. Rightmost derivation traced out in reverse
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).Leftmost derivation

49. Which of the following statements is false ?
a. An unambiguous grammar has same leftmost and rightmost derivation
b. An LL(1) parser is a top-down parser
c. LALR is more powerful than SLR
d. An ambiguous grammar can never be LR(k) for any k
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).An unambiguous grammar has same leftmost and rightmost derivation

50. Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at
a. Edit-time
b. Compile-time
c. Link-time
d. Load-time
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Link-time

Page 5 of 6