Compiler Design questions — page 1 of 5

Q28

GATE CS 2026 CS-1ParsingMSQ1 mark
Which of the following statements is/are true?
More than one option can be correct.
Show answer without attempting

Answer: C

Q42

GATE CS 2026 CS-1Optimization and Data FlowMCQ2 marks−2/3 if wrong
Consider the control flow graph shown in the figure.

Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5?

Note: All the variables are integers.
Question figure
Show answer without attempting

Answer: D

Q53

GATE CS 2026 CS-1Syntax Directed TranslationMSQ2 marks
Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.

DD is the start symbol, and intint, floatfloat and idid are the three terminals. The non-terminal V1V_1 is the same as VV and the non-terminal D1D_1 is the same as DD. Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function putput updates the symbol table with the type information for an identifier.

Let P and Q be the languages specified by grammars G1 and G2, respectively.

Which of the following statements is/are true?
Question figure
More than one option can be correct.
Show answer without attempting

Answer: A, B, D

Q17

GATE CS 2026 CS-2Runtime EnvironmentsMCQ1 mark−1/3 if wrong
In C runtime environment, which one of the following is stored in heap?
Show answer without attempting

Answer: C

Q35

GATE CS 2026 CS-2Lexical AnalysisNAT1 mark
A lexical analyzer uses the following token definitions
* letter→[A−Za−z]letter \rightarrow [A - Za - z]
* digit→[0−9]digit \rightarrow [0 - 9]
* id→letter(letter∣digit)∗id \rightarrow letter (letter \mid digit)^*
* number→digit+number \rightarrow digit^+
* ws→(blank∣tab∣newline)+ws \rightarrow (blank \mid tab \mid newline)^+

For the string given below,

x1  23mm  78  y  7z  zz5  14A  8H  AaYcDx1 \; 23mm \; 78 \; y \; 7z \; zz5 \; 14A \; 8H \; AaYcD

the number of tokens (excluding wsws) that will be produced by the lexical analyzer is __________. (answer in integer)
Show answer without attempting

Answer: 13

Q41

GATE CS 2026 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the canonical LR(0)LR(0) parsing of the grammar below using terminals {a,b,c}\{a, b, c\} and non-terminals {A,B,C,S}\{A, B, C, S\} with SS as the start symbol.

S→ACBS \rightarrow ACB

A→aA∣ϵA \rightarrow aA \mid \epsilon

C→cC∣ϵC \rightarrow cC \mid \epsilon

B→bB∣bB \rightarrow bB \mid b

Which one of the following options gives the number of shift-reduce conflicts that will occur in the LR(0)LR(0) ACTION table?
Show answer without attempting

Answer: D

Q45

GATE CS 2026 CS-2Optimization and Data FlowMCQ2 marks−2/3 if wrong
Consider the control flow graph given below.

Which one of the following options is the set of live variables at the exit point of each basic block?
Question figure
Show answer without attempting

Answer: A

Q12

GATE CS 2025 CS-1Lexical AnalysisMCQ1 mark−1/3 if wrong
Which ONE of the following statements is FALSE regarding the symbol table?
Show answer without attempting

Answer: C

Q13

GATE CS 2025 CS-1Optimization and Data FlowMCQ1 mark−1/3 if wrong
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
Show answer without attempting

Answer: B

Q46

GATE CS 2025 CS-1ParsingMSQ2 marks
Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q52

GATE CS 2025 CS-1Intermediate CodeNAT2 marks
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)
1001: i = 1
1002: j = 1
1003: t1 = 10*i
1004: t2 = t1+j
1005: t3 = 8*t2
1006: t4 = t3-88
1007: a[t4] = 0.0
1008: j = j+1
1009: if j <= 10 goto 1003
1010: i = i+1
1011: if i <= 10 goto 1002
1012: i = 1
1013: t5 = i-1
1014: t6 = 88*t5
1015: a[t6] = 1.0
1016: i = i+1
1017: if i <= 10 goto 1013
Show answer without attempting

Answer: 6

Q21

GATE CS 2025 CS-2Intermediate CodeMCQ1 mark−1/3 if wrong
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:

(I) Backpatching can be used to generate code for Boolean expression in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.

Which ONE of the following options is CORRECT?
Show answer without attempting

Answer: C

Q22

GATE CS 2025 CS-2Syntax Directed TranslationMCQ1 mark−1/3 if wrong
Given the following syntax directed translation rules:

Rule 1: R→AB{B.i=R.i−1;A.i=B.i;R.i=A.i+1;}R \rightarrow AB \{B.i = R.i - 1; A.i = B.i; R.i = A.i + 1;\}
Rule 2: P→CD{P.i=C.i+D.i;D.i=C.i+2;}P \rightarrow CD \{P.i = C.i + D.i; D.i = C.i + 2;\}
Rule 3: Q→EF{Q.i=E.i+F.i;}Q \rightarrow EF \{Q.i = E.i + F.i;\}

Which ONE is the CORRECT option among the following?
Show answer without attempting

Answer: C

Q40

GATE CS 2025 CS-2ParsingMCQ2 marks−2/3 if wrong
Given a Context-Free Grammar GG as follows:

S→Aa∣bAc∣dc∣bdaS \rightarrow Aa \mid bAc \mid dc \mid bda
A→dA \rightarrow d

Which ONE of the following statements is TRUE?
Show answer without attempting

Answer: C

Q51

GATE CS 2025 CS-2ParsingMSQ2 marks
Consider two grammars G1G_1 and G2G_2 with the production rules given below:

G1:S→if E then S∣if E then S else S∣aG_1: S \rightarrow \text{if } E \text{ then } S \mid \text{if } E \text{ then } S \text{ else } S \mid a
E→bE \rightarrow b

G2:S→if E then S∣MG_2: S \rightarrow \text{if } E \text{ then } S \mid M
M→if E then M else S∣cM \rightarrow \text{if } E \text{ then } M \text{ else } S \mid c
E→bE \rightarrow b

where if,then,else,a,b,c\text{if}, \text{then}, \text{else}, a, b, c are the terminals.

Which of the following option(s) is/are CORRECT?
More than one option can be correct.
Show answer without attempting

Answer: C, D

Q26

GATE CS 2024 CS-1ParsingMSQ1 mark
Which of the following is/are Bottom-Up Parser(s)?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q37

GATE CS 2024 CS-1Syntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the following syntax-directed definition (SDD).
S→DHTU{S.val=D.val+H.val+T.val+U.val;}S \to DHTU \{ S.val = D.val + H.val + T.val + U.val; \}
D→"M"D1{D.val=5+D1.val;}D \to \text{"M"}D_1 \{ D.val = 5 + D_1.val; \}
D→ϵ{D.val=−5;}D \to \epsilon \{ D.val = -5; \}
H→"L"H1{H.val=5∗10+H1.val;}H \to \text{"L"}H_1 \{ H.val = 5 * 10 + H_1.val; \}
H→ϵ{H.val=−10;}H \to \epsilon \{ H.val = -10; \}
T→"C"T1{T.val=5∗100+T1.val;}T \to \text{"C"}T_1 \{ T.val = 5 * 100 + T_1.val; \}
T→ϵ{T.val=−5;}T \to \epsilon \{ T.val = -5; \}
U→"K"{U.val=5;}U \to \text{"K"} \{ U.val = 5; \}
Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute S.valS.val)?
Show answer without attempting

Answer: A

Q39

GATE CS 2024 CS-1Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the following pseudo-code.
L1:t1=−1L1: t1 = -1
L2:t2=0L2: t2 = 0
L3:t3=0L3: t3 = 0
L4:t4=4∗t3L4: t4 = 4 * t3
L5:t5=4∗t2L5: t5 = 4 * t2
L6:t6=t5∗ML6: t6 = t5 * M
L7:t7=t4+t6L7: t7 = t4 + t6
L8:t8=a[t7]L8: t8 = a[t7]
L9:if t8<=max goto L11L9: \text{if } t8 <= max \text{ goto } L11
L10:t1=t8L10: t1 = t8
L11:t3=t3+1L11: t3 = t3 + 1
L12:if t3<M goto L4L12: \text{if } t3 < M \text{ goto } L4
L13:t2=t2+1L13: t2 = t2 + 1
L14:if t2<N goto L3L14: \text{if } t2 < N \text{ goto } L3
L15:max=t1L15: max = t1
Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively?
Show answer without attempting

Answer: D

Q21

GATE CS 2024 CS-2Lexical AnalysisMCQ1 mark−1/3 if wrong
Consider the following two sets:
Set XSet Y
P. Lexical Analyzer1. Abstract Syntax Tree
Q. Syntax Analyzer2. Token
R. Intermediate Code Generator3. Parse Tree
S. Code Optimizer4. Constant Folding
Which one of the following options is the CORRECT match from Set X to Set Y?
Show answer without attempting

Answer: B

Q29

GATE CS 2024 CS-2Syntax Directed TranslationMSQ1 mark
Which of the following statements is/are FALSE?
More than one option can be correct.
Show answer without attempting

Answer: B, D

0/200 correct0 marks

Related topics in GATE CS