GATE||Compiler design || Pyq (2010 to 2025)

Last Updated :
Discuss
Comments

Question 1

Which ONE of the following statements is FALSE regarding the symbol table?

[GATE 2025|| SET-1 MCQ || 1-mark]

  • Symbol table is responsible for keeping track of the scope of variables.

  • Symbol table can be implemented using a binary search tree.

  • Symbol table is not required after the parsing phase.

  • Symbol table is created during the lexical analysis phase.

Question 2

Consider evaluating the following expression tree on a machine with load-store architecture in which memory can be accessed only through load and store instructions. The variables a, b, c, d and e initially stored in memory. The binary operators used in this expression tree can be evaluate by the machine only when the operands are in registers. The instructions produce results only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression? 

P
.

[GATE 2011 || MCQ|| 2-mark]

  • 2

  • 9

  • 5

  • 3

Question 3

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:

[GATE 2012 || MCQ|| 2-mark]

  • u
    .


  • T
    .


  • F
    .

  • W
    .

Question 4

Which languages necessarily need heap allocation in the runtime environment? [GATE 2010 || MCQ|| 1-mark]


  • Those that support recursion

  • Those that use dynamic scoping

  • Those that allow dynamic data structures

  • Those that use global variables

Question 5

Which one of the following is True at any valid state in shift-reduce parsing?


  • Viable prefixes appear only at the bottom of the stack and not inside

  • Viable prefixes appear only at the top of the stack and not inside

  • The stack contains only a set of viable prefixes

  • The stack never contains viable prefixes

Question 6

Consider the following grammar G.

S -> F | H

F -> p | c

H ->d | c

Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?

S1: LL(1) can parse all strings that are generated using grammar G.

S2: LR(1) can parse all strings that are generated using grammar.

[GATE 2015||SET-3 MCQ || 2-mark]


  • Only S1

  • Only S2

  • Both S1 and S2

  • Neither S1 nor S2

Question 7

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||SET-2 MCQ|| 1-mark]


  • + is left associative, while * is right associative

  • + is right associative, while * is left associative

  • Both + and * are right associative

  • Both + and * are left associative

Question 8

A conical set of items is given below:

S 🡪 L.  > R

Q 🡪 R.

On input symbol < the set has:-

[GATE 2014||SET-1 MCQ|| 2-mark]


  • a shift-reduce conflict and a reduce-reduce conflict.

  • a shift-reduce conflict but not a reduce-reduce conflict.

  • a reduce-reduce conflict but not a shift-reduce conflict.

  • neither a shift-reduce nor a reduce-reduce conflict.

Question 9

For the grammar below, a partial LL(1) parsing table is also presented alon with the grammar. Entries that need to be filled are indicated as E1, E2 and E3. ε is the empty string, $ indicates end of input, and | separates alternate right hand sides of productions.

S -> a A b B | b A a B | ε

A -> S

B -> S

Screenshot-2025-10-14-181518
.

The FIRST and FOLLOW sets for the non-terminals A and B are:-

[GATE 2012 || MCQ|| 2-mark]

  • FIRST(A) = {a,b,ε} = FIRST(B)

      FOLLOW(A) = {a,b}

    FOLLOW(B) = {a,b,$}


  • FIRST(A) = {a,b,$}

        FIRST(B) = {a,b,ε}

        FOLLOW(A) = {a,b}

        FOLLOW(B) = {$}

  • FIRST(A) = {a,b,ε} = FIRST(B)

        FOLLOW(A) = {a,b}

        FOLLOW(B) = ∅


  • FIRST(A) = {a,b} = FIRST(B)

        FOLLOW(A) = {a,b}

        FOLLOW(B) = {a,b}


Question 10

Consider two binary operators ‘↑’ and ‘↓’ with the precedence of operator ↓ being lower than that of the operator ↑. Operator ↑ is right associative while operator ↓ is left associative. Which one of the following represents the parse tree for expression (7↓3↑4↑3↓2) ?

[GATE 2011 || MCQ|| 2-mark]  

  • Screenshot-2025-10-14-172327
    .


  • Screenshot-2025-10-14-172336
    .


  • Screenshot-2025-10-14-171404
    .


  • Screenshot-2025-10-14-171427
    .


There are 63 questions to complete.

Take a part in the ongoing discussion