CD |Gate-2014| Previous Year Questions| Set-7

Set-15 GATE-2006 CD

CD |Gate-2014| Compiler Design

1. Which one of the following is FALSE?  [GATE – 2014]

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.

Answer : d)

2. A canonical set of items is given below  [GATE – 2014]

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 and a reduce-reduce conflict
c. a reduce-reduce conflict but not a shift-reduce conflict.
d. a shift-reduce conflict but not a reduce-reduce conflict.

Answer : b)

3. Let L be a language and L’ be its complement. Which one of the following is NOT a viable possibility?   [GATE – 2014]

a. Neither L nor L’ is recursively enumerable (r.e.).
b. One of L and L’ is r.e. but not recursive; the other is not r.e.
c. Both L and L’ are r.e. but not recursive.
d. Both L and L’ are recursive

Answer : c)

4. Which of the regular expressions given below represent the following DFA?   [GATE – 2014]

I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1

a. I and II only
b. I and III only
c. III and II only
d. I, II and III

Answer : b)

5. 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?  [GATE – 2014]

a. + is left associative, while ∗ is right associative
b. Both + and ∗ are right associative
c. Both + and ∗ are left associative
d. + is right associative, while ∗ is left associative

Answer : d)

6. Which one of the following is NOT performed during compilation?  [GATE – 2014]

a. Dynamic memory allocation
b. Type checking
c. Symbol table management
d. Inline expansion

Answer : a)

7.  For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.

  t0 = i ∗ 1024
  t1 = j ∗ 32
  t2 = k ∗ 4
  t3 = t1 + t0
  t4 = t3 + t2 
t5 = X[t4]

Which one of the following statements about the source code for the C program is CORRECT?  [GATE – 2014]

a. X is declared as “int X[32][32][8]”.
b. X is declared as “int X[4][1024][32]”.
c. X is declared as “char X[4][32][8]”.
d. X is declared as “char X[32][16][2]”.

Answer : a)

8. Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the

maximum possible value of the expression represented by the tree is ___.  [GATE – 2014]

a. 6
b. 7
c. 8
d. 9

Answer : a)
CD |Gate-2014|

9. One of the purposes of using intermediate code in compilers is to :  [GATE – 2014]

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.

Answer : c)

10. Which of the following statements are CORRECT? 1)Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2)Automatic garbage collection is essential to implement recursion. 3)Dynamic allocation of activation records is essential to implement recursion. 4)Both heap and stack are essential to implement recursion.   [GATE – 2014] 

a. 1 and 2 only
b. 2 and 3 only
c. 3 and 4 only
d. 1 and 3 only

Answer : d)

11. A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below?   4, 7, 6, 1, 7, 6, 1, 2, 7, 2  [GATE – 2014]

a. 6
b. 7
c. 8
d. 9

Answer : a)
CD |Gate-2014|


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *