2000Questions per year2026
Questions 1–4 of 4
Consider the following two sets:
Which one of the following options is the CORRECT match from Set X to Set Y ?
Which one of the following options is the CORRECT match from Set X to Set Y ?
Answer: (B)
What each compiler phase gives or uses:
- P. Lexical Analyzer gives tokens (2)
- Q. Syntax Analyzer gives a parse tree (3)
- R. Intermediate Code Generator uses the abstract syntax tree / IR (1)
- S. Code Optimizer does constant folding (4)
Answer: P-2; Q-3; R-1; S-4
- P. Lexical Analyzer gives tokens (2)
- Q. Syntax Analyzer gives a parse tree (3)
- R. Intermediate Code Generator uses the abstract syntax tree / IR (1)
- S. Code Optimizer does constant folding (4)
Answer: P-2; Q-3; R-1; S-4
Match the following according to input (from the left column) to the complier phase (in the right column) that processes it.
Answer: (C)
Phase that takes each input:
- Syntax tree is processed by the semantic analyzer (iii)
- Character stream is processed by the lexical analyzer (iv)
- Intermediate representation is processed by the code generator (i)
- Token stream is processed by the syntax analyzer (ii)
Answer: P-(iii), Q-(iv), R-(i), S-(ii)
- Syntax tree is processed by the semantic analyzer (iii)
- Character stream is processed by the lexical analyzer (iv)
- Intermediate representation is processed by the code generator (i)
- Token stream is processed by the syntax analyzer (ii)
Answer: P-(iii), Q-(iv), R-(i), S-(ii)
Match the following:
Answer: (C)
Each pair has a reason:
- P, Lexical analysis: the scanner is built as a DFA, and DFA minimization cuts the number of states in it. So P-2.
- Q, Parsing: the parser applies the grammar productions to the tokens and builds the production (parse) tree. So Q-4.
- R, Register allocation: variables that are live at the same time are joined in an interference graph, and coloring that graph with one color per register gives the allocation. So R-1.
- S, Expression evaluation: an expression tree is evaluated by post-order traversal, which visits both operands before the operator. So S-3.
Answer: (C)
- P, Lexical analysis: the scanner is built as a DFA, and DFA minimization cuts the number of states in it. So P-2.
- Q, Parsing: the parser applies the grammar productions to the tokens and builds the production (parse) tree. So Q-4.
- R, Register allocation: variables that are live at the same time are joined in an interference graph, and coloring that graph with one color per register gives the allocation. So R-1.
- S, Expression evaluation: an expression tree is evaluated by post-order traversal, which visits both operands before the operator. So S-3.
Answer: (C)
Match all items in Group 1 with correct options from those given in Group 2.
Answer: (B)
Correct Option: B
Lexical analysis uses regular expressions.
Pushdown automata go with context free grammar. This belongs to syntax analysis.
Code optimization is where dataflow analysis is done.
Code generation is where register allocation is done.
Keep practising