Compiler Quiz 2 (III Cse C)

30 Questions | Total Attempts: 158

SettingsSettingsSettings
Please wait...
Compiler Quiz 2 (III Cse C)


Questions and Answers
  • 1. 
    The address code involves
    • A. 

      Exactly 3 address

    • B. 

      At most Three address

    • C. 

      No unary operators

    • D. 

      None of the mentioned

  • 2. 
    An intermediate code form is
    • A. 

      Post-fix Notation

    • B. 

      Syntax Trees

    • C. 

      Three address code

    • D. 

      All of the mentioned

  • 3. 
    The graph that shows basic blocks and their successor relationship is called
    • A. 

      Dag

    • B. 

      Flow Graph

    • C. 

      Control Graph

    • D. 

      Hamilton Graph

  • 4. 
    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

  • 5. 
    Consider the following C code segment. for (i = 0, i { for (j=0; 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

  • 6. 
    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

  • 7. 
    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

  • 8. 
    Consider the following source code :   c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?
    • A. 

      c = a + b    t = b * e    a = d – e    b = d/t    c = a

    • B. 

      c = a + b       d = c       c = c – e       a = d – e       b = d/b

    • C. 

      d = c      c = c – e      a = d – e      b = b * e      b = d/b

    • D. 

      None of the above

  • 9. 
    Peephole optimization is form of
    • A. 

      Loop optimization

    • B. 

      Local optimization

    • C. 

      Constant folding

    • D. 

      Data flow analysis

  • 10. 
    In compiler terminology reduction in strength means
    • A. 

      Replacing run time computation by compile time computation

    • B. 

      Removing common subexpression

    • C. 

      Removing loop invariant computation

    • D. 

      Replacing a costly operation by a relatively cheaper one

  • 11. 
    Substitution of values for names (whose values are constants) is done in
    • A. 

      Local optimization

    • B. 

      Loop optimization

    • C. 

      Constant folding

    • D. 

      Strength reduction

  • 12. 
    The method which merges the bodies of two loops is
    • A. 

      Loop rolling

    • B. 

      Loop Jamming

    • C. 

      Constant folding

    • D. 

      None of these

  • 13. 
    Syntax directed translation scheme is desirable because
    • A. 

      It is based on the syntax

    • B. 

      Its description is independent of any implementation

    • C. 

      It is easy to modify  

    • D. 

      All of these

  • 14. 
    The optimization technique which is typically applied on loops is
    • A. 

      Removal of invariant computation

    • B. 

      Peephole optimization

    • C. 

      Constant folding

    • D. 

      All of these

  • 15. 
    The graph that shows basic blocks and their successor relationship is called
    • A. 

      DAG

    • B. 

      Flow graph

    • C. 

      Control graph

    • D. 

      Hamiltonian graph

  • 16. 
    An intermediate code form is
    • A. 

      Postfix notation

    • B. 

      Syntax trees

    • C. 

      Three address code

    • D. 

      All of these

  • 17. 
    Input to code generator
    • A. 

      Source code

    • B. 

      Intermediate code

    • C. 

      Target code

    • D. 

      All of the above

  • 18. 
    The identification of common sub-expression and replacement of run-time computations by compile-time computations is
    • A. 

      Local optimization

    • B. 

      Loop optimization

    • C. 

      Constant folding

    • D. 

      Data flow analysis

  • 19. 
    Local and loop optimization in turn provide motivation for
    • A. 

      Data flow analysis

    • B. 

      Constant folding

    • C. 

      Peep hole optimization

    • D. 

      DFA and constant folding

  • 20. 
    An optimizing compiler
    • A. 

      Is optimized to occupy less space

    • B. 

      Is optimized to take less time for execution

    • C. 

      Optimizes the code

    • D. 

      All of the above

  • 21. 
    A basic block can be analyzed by
    • A. 

      DAG

    • B. 

      A flow graph

    • C. 

      A graph with cycles

    • D. 

      None of the above

  • 22. 
    A pictorial representation of the value computed by each statement in the basic block is
    • A. 

      Tree

    • B. 

      DAG

    • C. 

      Graph

    • D. 

      None of the above

  • 23. 
    Boolean expressions have following purposes
    • A. 

      Computing logical values

    • B. 

      Used as conditional expressions

    • C. 

      Both a &b

    • D. 

      None of the above

  • 24. 
    __________can be used to generate code for Boolean expressions and flow of-control statements in one pass.
    • A. 

      Backpatching

    • B. 

      Code-generator

    • C. 

      Parser

    • D. 

      Static checker

  • 25. 
    Principal methods of representing the value of boolean expression
    • A. 

      Encoding true & false numerically

    • B. 

      To evaluate boolean expression analogously to an arithmetic expression

    • C. 

      Implementing boolean expression by flow of control

    • D. 

      All of the above

Back to Top Back to top