Skip to content

GATE CS Compiler Design questions

Practise Compiler Design questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2024Compiler DesignParsing (LL, LR)NAT · 2 marks
Let G=(V,Σ,S,P)G=(V, \Sigma, S, P) be a context-free grammar in Chomsky Normal Form with Σ={a,b,c}\Sigma=\{a, b, c\} and VV containing 1010 variable symbols including the start symbol SS. The string w=a30b30c30w=a^{30} b^{30} c^{30} is derivable from SS. The number of steps (application of rules) in the derivation S→∗wS \rightarrow^* w is __________.
Official PYQ2024Compiler DesignLexical AnalysisMCQ · 1 mark
​​​Consider the following two sets: …
Official PYQ2024Compiler DesignSyntax-directed TranslationMSQ · 1 mark
​​​​​Which of the following statements is/are FALSE?
Official PYQ2024Compiler DesignParsing (LL, LR)MSQ · 2 marks
​​​​Consider a context-free grammar G\text{G} with the following 33 rules. S→aS,S→aSbS,S→cS \rightarrow a S, S \rightarrow a S b S , S \rightarrow c Let w∈L(G)w \in L(G). Let na(w),nb(w),nc(w)n_{a}(w), n_{b}(w), n_{c}(w) denote the number of times a,b,ca, b, c occur in ww, respectively. Which of the following statements is/are TRUE?
Official PYQ2024Compiler DesignParsing (LL, LR)NAT · 2 marks
Consider the following augmented grammar, which is to be parsed with a SLR\text{SLR} parser. The set of terminals is {a,b,c,d,#,@}\{a, b, c, d, \#, @\} S′→SS→SS∣Aa∣bAc∣Bc∣bBaA→d#B→@\begin{array}{l} S^{\prime} \rightarrow S \\ S \rightarrow S S|A a| b A c|B c| b B a \\ A \rightarrow d \# \\ B \rightarrow @ \end{array} Let …
Official PYQ2023Compiler DesignLexical AnalysisMCQ · 1 mark
Consider the following statements regarding the front-end and back-end of a compiler. S1: The front-end includes phases that are independent of the target hardware. S2: The back-end includes phases that are specific to the target hardware. S3: The back-end includes phases that are specific to the programming language used in the source code. Identify the …
Official PYQ2023Compiler DesignRuntime EnvironmentsMCQ · 2 marks
Consider the following program: int main() { f1 (); f2(2); f3(); return (0); } int f1 () { return(1); } int f2 (int X) { f3(); if (X==1); return f1 (); else return (X * f2 (X - 1)); } int f3 () { return (5); } Which one of the following options represents the activation tree corresponding to the main function?
Official PYQ2023Compiler DesignData Flow Analyses: Constant Propagation, Liveness, CSEMCQ · 2 marks
Consider the control flow graph shown. Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?
Official PYQ2023Compiler DesignSyntax-directed TranslationNAT · 2 marks
Consider the syntax directed translation given by the following grammar and semantic rules. Here N,I,FN, I, F and BB are non-terminals. NN is the starting non-terminal, and #,0\#, \mathbf{0} and 1\mathbf{1} are lexical tokens corresponding to input letters “#", “0" and “1",\text{“\#", “0" and “1"}, respectively. X.valX.val denotes the synthesized attribute (a …
Official PYQ2022Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which one of the following statements is TRUE?\text{TRUE}?
Official PYQ2022Compiler DesignParsing (LL, LR)NAT · 1 mark
Consider the augmented grammar with {+,∗,(,),id}\{ +, {\ast}, (,),\text{id} \} as the set of terminals. S’→SS’ \rightarrow S S→S+R  ∣  RS \rightarrow S + R\; |\; R R→R∗P  ∣  PR \rightarrow R {\ast} P \;| \;P P→(S)  ∣  idP \rightarrow (S)\; |\; \text{id} If I0I_{0} is the set of two LR(0)\textit{LR}(0) items {[S’→S.],[S→S.+R]}\{ [S’ \rightarrow S.], [S \rightarrow S. + R] \}, then …
Official PYQ2022Compiler DesignSyntax-directed TranslationNAT · 2 marks
Consider the following grammar along with translation rules. …
Official PYQ2021Compiler DesignRuntime EnvironmentsMCQ · 1 mark
Consider the following statements. S1:S_1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree. S2:S_2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree. Which one of the following options is correct?
Official PYQ2021Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following statements. S1:S_1: Every SLR(1)\text{SLR(1)} grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1)\text{SLR(1)}. S2:S_2: For any context-free grammar, there is a parser that takes at most O(n3)O(n^3) time to parse a string of length nn. Which one of the following options is correct?
Official PYQ2021Compiler DesignSyntax-directed TranslationMCQ · 2 marks
​​​Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT)\text{(SDT)} actions, given as pseudo-code …
Official PYQ2021Compiler DesignParsing (LL, LR)MCQ · 2 marks
Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}\{a,b,c,d,f\}. …
Official PYQ2021Compiler DesignLocal OptimizationNAT · 2 marks
Consider the following CC code segment: a = b + c; e = a + 1; d = b + c; f = d + 1; g = e + f; In a compiler, this code segment is represented internally as a directed acyclic graph (DAG)\text{(DAG)}. The number of nodes in the DAG\text{DAG} is _____________
Official PYQ2021Compiler DesignLexical AnalysisMCQ · 1 mark
Consider the following ANSI C\text{ANSI C} program: int main () { Integer x; return 0; } Which one of the following phases in a seven-phase CC compiler will throw an error?
Official PYQ2021Compiler DesignIntermediate Code GenerationMCQ · 1 mark
In the context of compilers, which of the following is/are NOT\text{NOT} an intermediate representation of the source program?
Official PYQ2021Compiler DesignLocal OptimizationMCQ · 2 marks
​​​​​​Consider the following ANSI C\text{ANSI C} code segment: z=x + 3 + y->f1 + y->f2; for (i = 0; i < 200; i = i + 2) { if (z > i) { p = p + x + 3; q = q + y->f1; } else { p = p + y->f2; q = q + x + 3; } } Assume that the variable yy points to a struct\textsf{struct} (allocated on the heap) containing two fields f1\textsf{f1} and …