Question
Consider the following syntax-directed definition (SDD).
Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute )?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2024 answer key
Solution
Parse the input string "MMLK" according to and evaluate the synthesized attribute bottom-up.
For the input string "MMLK", the unique derivation from matches D to "MM", H to "L", T to , and U to "K":
- :
- :
- :
- :
Summing at the root:
Option (A)
Forgetting that still derives with even when 'C' does not appear in the input string (which would give 50).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
- Question
- 37 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.