Loading

SET 2


  Question 1

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


  •  
    .

     Correct answer is :D

     Solution :
      x = 4 5 => x = 20 is not an example of common sub-expression but it is constant folding. In constant folding expression consisting of constants will be replaced by their final value at compile time, rather than doing the calculation in run-time.

  •   Question 2

    A canonical set of items is given below
    s -> L.> R
    Q -> 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.


  •  
    .

     Correct answer is :D

     Solution :
      From the diagram, we can see that there is no shift- reduce or reduce-reduce conflict.


  •   Question 3

    Consider the grammar defined by the following production rules, with two operators * and +
    S -> T *P
    T -> U | T*U
    P -> Q + P | Q
    Q ->Id
    U -> Id
    Which one of the following is TRUE?


    A : + is left associative, while * is right associative
    B : + is right associative, while * is left associative
    C : Both + and * are right associative
    D : Both + and * are left associative


  •  
    .

     Correct answer is :B

     Solution :
      S->T P
    T-> U | T *U
    P -> Q + P |Q
    Q -> Id
    U -> Id
    As the production rule T->TU is defined as left recursive rule, so * is left associate operator.
    As the production rule P->Q + P is defined as right recursive rule, so + is right associative operator.

  •   Question 4

    Which one of the following is NOT performed during compilation?

    A : Dynamic memory allocation
    B : Type checking
    C : Symbol table management
    D : Inline expansion


  •  
    .

     Correct answer is :A

     Solution :
      Dynamic memory allocation is done after compilation when we have an exe file which is to be loaded in the memory dynamically.

  •   Question 5

    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 compliers.
    D : improve the register allocation.


  •  
    .

     Correct answer is :C

     Solution :
      Intermediate code is machine independent code which makes it easy to retarget the compiler to generate code for newer and different processors.

  •   Question 6

    Consider the basic block given below.
    a = b+ c
    c= a+ d
    d= b+ c
    e= d+ b
    a= e+ b
    The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are


    A : 6 and 6
    B : 8 and 10
    C : 9 and 12
    D : 4 and 14


  •  
    .

     Correct answer is :A


  • MY REPORT
    TOTAL = 6
    ANSWERED =
    CORRECT / TOTAL = /6
    POSITIVE SCORE =
    NEGATIVE SCORE =
    FINAL SCORE =