Skip to content
Early access — you're among the first to try PYQLabs. Share feedback

GATE CSE & IT

2,749 questions · 40 years · 20 subjects

Public preview: use this branch page to find high-signal topics and keyed questions. Explanations are being added selectively, starting with recent and recurring concepts.

Worked PYQ examples

Open a few full study-layer explanations before signing in.

Browse explained PYQs →

High-yield topics

All trends →

Practice CSE & IT PYQs

80 questions shown in Compiler Design. Filter for cleaner practice sessions.

Showing Compiler Design PYQs from CSE & IT.
2026 PYQ

Consider the following C statements: char str1 = "Hello; / Statement S1 */ char str2 = "Hello;"; / Statement S2 */ int str3 = "Hello"; / Statement S3 */ Which of the following opti...

Compiler Design/MCQ/answer key/explanation
2026 PYQ

Which of the following statements is/are true?

Compiler Design/MCQ/answer key/explanation
2026 PYQ

$$ \text { Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. } $$ SDD1 Grammar(G1) $$ \text { Semantic Rules } $$ $$ \mathrm{D} \rightarro...

Compiler Design/MCQ/answer key/explanation
2026 PYQ

Consider the canonical $L R(0)$ parsing of the grammar below using terminals $\{a, b, c\}$ and non-terminals $\{A, B, C, S\}$ with $S$ as the start symbol. $$ \begin{aligned} & S \...

Compiler Design/MCQ/answer key/explanation
2026 PYQ

A lexical analyzer uses the following token definitions letter → [A - Za - z] digit → [0-9] id → letter (letter $\mid$ digit)* number → digit $^{+}$ ws → (blank | tab | newline) ${...

Compiler Design/NAT/explanation
2025 PYQ

Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?

Compiler Design/MSQ/answer key/explanation
2025 PYQ

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

Compiler Design/MCQ/answer key/explanation
2025 PYQ

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

Compiler Design/MCQ/answer key/explanation
2025 PYQ

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) $$\begin{aligned} & \text {...

Compiler Design/NAT/explanation
2025 PYQ

Given the following syntax directed translation rules : Rule 1 : $R \rightarrow A B\{B . i=R . i-1 ; A . i=B . i R . i=A . i+1 ;\}$ Rule 2 : $P \rightarrow C D\{P . i=C . i+D . i ;...

Compiler Design/MCQ/answer key/explanation
2025 PYQ

Consider the following statements about the use of backpatching in a compiler for (I) Backpatching can be used to generate code for Boolean expression in one pass. (II) Backpatchin...

Compiler Design/MCQ/answer key/explanation
2025 PYQ

Given a Context-Free Grammar G as follows : $S \rightarrow A a|b a c| d c \mid b d a$ $A \rightarrow d$ Which ONE of the following statements is TRUE?

Compiler Design/MCQ/answer key/explanation
2025 PYQ

Consider two grammars $G_1$ and $G_2$ with the production rules given below: $G_1: S \rightarrow$ if $E$ then $S \mid$ if $E$ then $S$ else $S \mid a$ $$\mathrm{E} \rightarrow \mat...

Compiler Design/MSQ/answer key/explanation
2024 PYQ

Which of the following is/are Bottom-Up Parser(s)?

Compiler Design/MSQ/answer key/explanation
2024 PYQ

Consider the following syntax-directed definition (SDD). S → DHTU { S.val = D.val + H.val + T.val + U.val; } D → “M” D 1 { D.val = 5 + D 1 .val; } D → ε { D.val = –5; } H → “L” H 1...

Compiler Design/MCQ/answer key/explanation
2024 PYQ

Consider the following grammar $G$, with $S$ as the start symbol. The grammar $G$ has three incomplete productions denoted by (1), (2), and (3). $$S \rightarrow d a T \mid \underli...

Compiler Design/MCQ/answer key/explanation
2024 PYQ

Consider the following pseudo-code. L1: t1 = -1 L2: t2 = 0 L3: t3 = 0 L4: t4 = 4 * t3 L5: t5 = 4 * t2 L6: t6 = t5 * M L7: t7 = t4 + t6 L8: t8 = a[t7] L9: if t8 L10: t1 = t8 L11: t3...

Compiler Design/MCQ/answer key/explanation
2024 PYQ

Consider the following two sets: Set X P. Lexical Analyzer Q. Syntax Analyzer R. Intermediate Code Generator S. Code Optimizer Set Y 1. Abstract Syntax Tree 2. Token 3. Parse Tree...

Compiler Design/MTF/answer key/explanation
2024 PYQ

Which of the following statements is/are FALSE?

Compiler Design/MSQ/answer key/explanation
2024 PYQ

Consider the following context-free grammar where the start symbol is S and the set of terminals is {a,b,c,d}. $ S \rightarrow AaAb \mid BbBa $ $ A \rightarrow cS \mid \epsilon $ $...

Compiler Design/MCQ/answer key/explanation
2024 PYQ

Consider the following expression: $x[i] = (p + r) * -s[i] + \frac{u}{w}$. The following sequence shows the list of triples representing the given expression, with entries missing...

Compiler Design/MCQ/answer key/explanation
2024 PYQ

Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is $\{ a, b, c, d, \, \#, \, @ \}$ $S' \rightarrow S$ $S \rightarrow SS \;|\...

Compiler Design/NAT/explanation
2023 PYQ

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-en...

Compiler Design/MCQ/answer key/explanation
2023 PYQ

Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0 and 1 are...

Compiler Design/NAT/explanation
2022 PYQ

Which one of the following statements is TRUE?

Compiler Design/MCQ/answer key/explanation
2022 PYQ

Consider the augmented grammar with {+, *, (, ), id} as the set of terminals. S' $$\to$$ S S $$\to$$ S + R | R R $$\to$$ R * P | P P $$\to$$ (S) | id If I 0 is the set of two LR(0)...

Compiler Design/NAT/explanation
2022 PYQ

Consider the following grammar along with translation rules. S $$\to$$ S 1 # T {S.val = S 1 .val * T.val} S $$\to$$ T {S.val = T.val} T $$\to$$ T 1 %R {T.val = T 1 .val $$ \div $$...

Compiler Design/NAT/explanation
2021 PYQ

Consider the following statements. S 1 : Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1). S 2 : For any context-free grammar, the...

Compiler Design/MCQ/answer key/explanation
2021 PYQ

Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code: P...

Compiler Design/MCQ/answer key/explanation
2021 PYQ

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?

Compiler Design/MCQ/answer key/explanation
2021 PYQ

Consider the following 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 -> f2; } else { p = p + y -> f2; q...

Compiler Design/MCQ/answer key/explanation
2021 PYQ

Consider the following C 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...

Compiler Design/NAT/explanation
2021 PYQ

In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

Compiler Design/MSQ/answer key/explanation
2021 PYQ

Consider the following augmented grammar with {#, @, <, >, a, b, c} as the set of terminals. S' → S S → S # cS S → SS S → S @ S → < S > S → a S → b S → c Let I 0 = CLOSURE({S' → ∙...

Compiler Design/NAT/explanation
2021 PYQ

For a statement S in a program, in the context of liveness analysis, the following sets are defined: USE(S): the set of variables used in S IN(S): the set of variables that are liv...

Compiler Design/MCQ/answer key/explanation
2020 PYQ

Consider the following statements. I. Symbol table is accessed only during lexical analysis and syntax analysis. II. Compilers for programming languages that support recursion nece...

Compiler Design/STMT/answer key/explanation
2020 PYQ

Consider the productions A $$ \to $$ PQ and A $$ \to $$ XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute, and i is an inherited...

Compiler Design/MCQ/answer key/explanation
2020 PYQ

Consider the following grammar. S $$ \to $$ aSB| d B $$ \to $$ b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is _______.

Compiler Design/NAT/explanation
2019 PYQ

Which one of the following kinds of derivation is used by LR parsers?

Compiler Design/MCQ/answer key/explanation
2019 PYQ

Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let $X_1, X_2, X_3, X_4, X_5$, and $X_6$ be the placeholders for the n...

Compiler Design/MCQ/answer key/explanation
2019 PYQ

Consider the augmented grammar given below : S' → S S → 〈L〉 | id L → L,S | S Let I 0 = CLOSURE ({[S' → ●S]}). The number of items in the set GOTO (I 0 , 〈 ) is: _____.

Compiler Design/NAT/explanation
2018 PYQ

A lexical analyzer uses the following patterns to recognize three tokens $${T_1},{T_2},$$ and $${T_3}$$ over the alphabet $$\left\{ {a,b,c} \right\}.$$ $$\eqalign{ & {T_1}:\,\,\,a?...

Compiler Design/MCQ/answer key/explanation
2018 PYQ

Which one of the following statements is FALSE?

Compiler Design/MCQ/answer key
2016 PYQ

Consider the following Syntax Directed Translation Scheme $$(SDTS),$$ with non-terminals $$\left\{ {S,A} \right\}$$ and terminals $$\left\{ {A,B} \right\}.$$ $$S \to aA$$ $$\,\,\,\...

Compiler Design/MCQ/answer key
2016 PYQ

Match the following: GROUP - 1 GROUP - 2 (P) Lexical analysis (i) Leftmost derivation (Q) Top down parsing (ii) Type checking (R) Semantic analysis (iii) Regular expressions (S) Ru...

Compiler Design/MTF/answer key
2016 PYQ

Which one of the following grammars is free from $$left$$ $$recursion$$?

Compiler Design/MCQ/answer key
2016 PYQ

Consider the following code segment. x = u - t; y = x * v; x = y + w; y = t - z; y = x * y; The minimum number of total variables required to convert the above code segment to stat...

Compiler Design/NAT
2016 PYQ

A student wrote two context-free grammars G1 and G2 for generating a single $$C$$-like array declaration. The dimension of the array is at least one. For example, $$${\mathop{\rm i...

Compiler Design/MCQ/answer key
2016 PYQ

The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity + High Left Binary _ Medium Right Binary * Low Le...

Compiler Design/NAT
2015 PYQ

In the context of abstract-syntax-tree $$(AST)$$ and control-flow-graph $$(CFG),$$ which one of the following is TRUE?

Compiler Design/MCQ/answer key
2015 PYQ

The least number of temporary variables required to create a three-address code in static single assignment form for the expression $$q + r / 3 + s - t * 5 + u * v/w$$ is _________...

Compiler Design/NAT
2015 PYQ

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

Compiler Design/MCQ/answer key
2015 PYQ

Consider the intermediate code given below. (1) i = 1 (2) j = 1 (3) t1 = 5 ∗ i (4) t2 = t1 + j (5) t3 = 4 ∗ t2 (6) t4 = t3 (7) a[t4] = -1 (8) j = j + 1 (9) if j<=5 goto (3) (10) i=...

Compiler Design/MCQ/answer key
2015 PYQ

Match the following: GROUP 1 GROUP 2 P. Lexical analysis 1. Graph coloring Q. Parsing 2. DFA minimization R. Register allocation 3. Post-order traversal S. Expression evaluation 4....

Compiler Design/MTF/answer key
2015 PYQ

Consider the following grammar $$G$$ $$\eqalign{ & \,\,\,\,\,\,\,S \to \,\,\,\,\,\,\,F|H \cr & \,\,\,\,\,\,F \to \,\,\,\,\,\,\,p|c \cr & \,\,\,\,\,\,H \to \,\,\,\,\,\,\,d|c \cr} $$...

Compiler Design/MCQ/answer key
2015 PYQ

Among simple $$LR (SLR) ,$$ canonical $$LR,$$ and look-ahead $$LR$$ $$(LALR),$$ which of the following pairs identify the method that is very easy to implement and the method that...

Compiler Design/MCQ/answer key
2014 PYQ

A canonical set of items is given below $$\eqalign{ & S \to L. > R \cr & Q \to R. \cr} $$ On input symbol < the set has

Compiler Design/MCQ/answer key
2014 PYQ

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...

Compiler Design/MCQ/answer key
2014 PYQ

One of the purposes of using intermediate code in compilers is to

Compiler Design/MCQ/answer key
2014 PYQ

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 b...

Compiler Design/MCQ/answer key
2014 PYQ

Consider the grammar defined by the following production rules, with two operators * and + $$\eqalign{ & S \to T*P \cr & T \to U\,|\,T*U \cr & P \to Q + P\,|\,Q \cr & Q \to id \cr...

Compiler Design/MCQ/answer key
2014 PYQ

Which one of the following is FALSE?

Compiler Design/MCQ/answer key
2013 PYQ

What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit-production ( i.e., of type $$A \to \varepsilon $$ and $$A...

Compiler Design/MCQ/answer key
2013 PYQ

Consider the following two sets of LR(1) items of an LR(1) grammar. $$\eqalign{ & X \to c.X,\,c/d\,\,\,\,\,\,\,\,X \to c.X,\$ \cr & X \to .cX,c/d\,\,\,\,\,\,\,\,X \to .cX,\$ \cr &...

Compiler Design/MCQ/answer key
2012 PYQ

Given the language L= { ab, aa, baa }, which of the following strings are in L* ? 1) abaabaaabaa 2) aaaabaaaa 3) baaaaabaaaab 4) baaaaabaa

Compiler Design/MCQ/answer key
2011 PYQ

In a compiler, keywords of a language are recognized during

Compiler Design/MCQ/answer key
2010 PYQ

Which languages necessarily need heap allocation in the runtime environment?

Compiler Design/MCQ/answer key
2010 PYQ

Which data structure in a compiler is used for managing information about variables and their attributes?

Compiler Design/MCQ/answer key
2010 PYQ

The grammar $$S \to aSa\,|\,\,bS\,|\,\,c$$ is

Compiler Design/MCQ/answer key
2010 PYQ

The program below uses six temporary variables a, b, c, d, e, f. a = 1 b = 10 c = 20 d = a + b e = c + d f = c + e b = c + e e = b + f d = 5 + e return d + f Assuming that all oper...

Compiler Design/MCQ/answer key
2009 PYQ

Match all items in Group 1 with correct options from those given in Group 2. Group 1 P. Regular expression Q. Pushdown automata R. Dataflow analysis S. Register allocation Group 2...

Compiler Design/MTF/answer key
2008 PYQ

Which of the following are true? I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can...

Compiler Design/STMT/answer key
2008 PYQ

Some code optimizations are carried out on the intermediate code because

Compiler Design/MCQ/answer key
2008 PYQ

An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if

Compiler Design/MCQ/answer key
2008 PYQ

Which of the following describes a handle (as applicable to LR-parsing) appropriately?

Compiler Design/MCQ/answer key
2007 PYQ

Consider the CFG with { S, A, B } as the non-terminal alphabet, { a, b } as the terminal alphabet, S as the start symbol and the following set of production rules: $$\eqalign{ & S...

Compiler Design/MCQ/answer key
2007 PYQ

Which one of the following is a top-down parser?

Compiler Design/MCQ/answer key
2007 PYQ

Consider the CFG with { S, A, B } as the non-terminal alphabet, { a, b } as the terminal alphabet, S as the start symbol and the following set of production rules: $$\eqalign{ & S...

Compiler Design/MCQ/answer key
2007 PYQ

Consider the grammar with non-terminals N = { S, C, S 1 }, terminals T = { a, b, i, t, e }, with S as the start symbol, and the following set of rules: $$\eqalign{ & S \to iCtS{S_1...

Compiler Design/MCQ/answer key
2007 PYQ

Consider the following two statements: P: Every regular grammar is LL(1) Q: Every regular set has a LR(1) grammar Which of the following is TRUE?

Compiler Design/STMT/answer key