The GATE 2024 Computer Science and Information Technology paper, Set 2: 65 questions for 100 marks in 180 minutes, with General Aptitude (15 marks) and the technical section (85 marks). Answers follow the official final answer key; every question has a short explanation.
Question 21
Consider the following two sets:
| Set X | Set Y |
|---|---|
| P. Lexical Analyzer | 1. Abstract Syntax Tree |
| Q. Syntax Analyzer | 2. Token |
| R. Intermediate Code Generator | 3. Parse Tree |
| S. Code Optimizer | 4. Constant Folding |
Which one of the following options is the CORRECT match from Set X to Set Y ?
Explanation
Answer: (B)
Match each phase with what it produces or does:
- P → 2. The lexical analyzer groups the input characters into lexemes and passes them on as tokens.
- Q → 3. The syntax analyzer checks the token stream against the grammar; the derivation it finds is a parse tree.
- R → 1. An abstract syntax tree, a compact tree of operators and operands without the parse tree's extra grammar nodes, is a common intermediate representation.
- S → 4. Constant folding, such as replacing
2 * 3by6at compile time, is a code optimization.
This gives P – 2; Q – 3; R – 1; S – 4. Option C swaps the two trees, and A and D misplace tokens and constant folding.
Answer: B
