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.
A short MSQ where the real trap is subspace closure, not calculation.
Shows how to convert graph wording into a reliable solve path.
Separates a common false intuition from the actual invariant.
Good example of wrong-option autopsy for algorithm statements.
Tests whether the standard theorem is being applied precisely.
Subjects
By Year
High-yield topics
All trends →Practice CSE & IT PYQs
80 questions shown in Compiler Design. Filter for cleaner practice sessions.
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...
Which of the following statements is/are true?
$$ \text { Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. } $$ SDD1 Grammar(G1) $$ \text { Semantic Rules } $$ $$ \mathrm{D} \rightarro...
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 \...
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) ${...
Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
Which ONE of the following statements is FALSE regarding the symbol table?
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 {...
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 ;...
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...
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?
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...
Which of the following is/are Bottom-Up Parser(s)?
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...
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...
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...
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...
Which of the following statements is/are FALSE?
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 $ $...
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...
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 \;|\...
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...
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...
Which one of the following statements is TRUE?
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)...
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 $$...
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...
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...
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?
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...
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...
In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?
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' → ∙...
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...
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...
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...
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 _______.
Which one of the following kinds of derivation is used by LR parsers?
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...
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: _____.
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?...
Which one of the following statements is FALSE?
Consider the following Syntax Directed Translation Scheme $$(SDTS),$$ with non-terminals $$\left\{ {S,A} \right\}$$ and terminals $$\left\{ {A,B} \right\}.$$ $$S \to aA$$ $$\,\,\,\...
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...
Which one of the following grammars is free from $$left$$ $$recursion$$?
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...
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...
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...
In the context of abstract-syntax-tree $$(AST)$$ and control-flow-graph $$(CFG),$$ which one of the following is TRUE?
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 _________...
Which one of the following is TRUE at any valid state in shift-reduce parsing?
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=...
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....
Consider the following grammar $$G$$ $$\eqalign{ & \,\,\,\,\,\,\,S \to \,\,\,\,\,\,\,F|H \cr & \,\,\,\,\,\,F \to \,\,\,\,\,\,\,p|c \cr & \,\,\,\,\,\,H \to \,\,\,\,\,\,\,d|c \cr} $$...
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...
A canonical set of items is given below $$\eqalign{ & S \to L. > R \cr & Q \to R. \cr} $$ On input symbol < the set has
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...
One of the purposes of using intermediate code in compilers is to
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...
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...
Which one of the following is FALSE?
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...
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 &...
Given the language L= { ab, aa, baa }, which of the following strings are in L* ? 1) abaabaaabaa 2) aaaabaaaa 3) baaaaabaaaab 4) baaaaabaa
In a compiler, keywords of a language are recognized during
Which languages necessarily need heap allocation in the runtime environment?
Which data structure in a compiler is used for managing information about variables and their attributes?
The grammar $$S \to aSa\,|\,\,bS\,|\,\,c$$ is
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...
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...
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...
Some code optimizations are carried out on the intermediate code because
An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
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...
Which one of the following is a top-down parser?
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...
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...
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?