Miscellaneous topics in Compiler design GATE CS PYQs

Last Updated :
Discuss
Comments

Question 1

Consider the following ANSI C program: 
 

int main () {
Integer x;
return 0;
}


Which one of the following phases in a seven-phase C compiler will throw an error?
 

  • Lexical analyzer
     

  • Syntax analyzer
     

  • Semantic analyzer
     

  • Machine dependent optimizer
     

Question 2

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.

Program main;
Var ...

Procedure A1;
Var ...
Call A2;
End A1

Procedure A2;
Var ...

Procedure A21;
Var ...
Call A1;
End A21

Call A21;
End A21

Call A1;
End main.

Consider the calling chain : Main->A1->A2->A21->A1 The correct set of activation records along with their access links is given by :

gatecs2012activationrecordgatecs2012activationrecord
  • A

  • B

  • C

  • D

Question 3

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

  • Edit-time

  • Compile-time

  • Link-time

  • Load-time

Question 4

Match all items in Group 1 with correct options from those given in Group 2.

Group 1                          Group 2
P. Regular expression 1. Syntax analysis
Q. Pushdown automata 2. Code generation
R. Dataflow analysis 3. Lexical analysis
S. Register allocation 4. Code optimization
  • P-4. Q-1, R-2, S-3

  • P-3, Q-1, R-4, S-2

  • P-3, Q-4, R-1, S-2

  • P-2, Q-1, R-4, S-3

Question 5

Let pA be a problem that belongs to the class NP. Then which one of the following is TRUE?

  • There is no polynomial time algorithm for pA

  • If pA can be solved deterministically in polynomial time,then P = NP

  • If pA is NP-hard, then it is NP-complete.

  • pA may be undecidable.

Question 6

A variable x is said to be live at a statement Si in a program if the following three conditions hold simultaneously:

1. There exists a statement Sj that uses x
2. There is a path from Si to Sj in the flow
graph corresponding to the program
3. The path has no intervening assignment to x
including at Si and Sj
Q59New

The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are

  • p, s, u

  • r, s, u

  • r, u

  • q, v

Question 7

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.
  • 1 and 2 only

  • 2 and 3 only

  • 3 and 4 only

  • 1 and 3 only

Question 8

Which one of the following is NOT performed during compilation?

  • Dynamic memory allocation

  • Type checking

  • Symbol table management

  • Inline expansion

Question 9

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

  • 6 and 6

  • 8 and 10

  • 9 and 12

  • 4 and 4

Question 10

Match the following:

(P) Lexical analysis       (i) Leftmost derivation
(Q) Top down parsing (ii) Type checking
(R) Semantic analysis (iii) Regular expressions
(S) Runtime environments (iv) Activation records
z1
  • A

  • B

  • C

  • D

There are 21 questions to complete.

Take a part in the ongoing discussion