GATE 2024 CS (CS1) – Question 37
Consider the SDD: S→DHTU {S.val=D.val+H.val+T.val+U.val}; D→"M"D1 {D.val=5+D1.val}; D→ε {D.val=−5}; H→"L"H1 {H.val=5*10+H1.val}; H→ε {H.val=−10}; T→"C"T1 {T.val=5*100+T1.val}; T→ε {T.val=−5}; U→"K" {U.val=5}. Given "MMLK" as the input, which is the CORRECT value of S.val?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) 55
Explanation
D: two M's give 5+5−5=5. H: one L gives 50−10=40. T: ε gives −5. U: K gives 5. Sum = 5+40−5+5 = 45... recomputing with D=5, H=40, T=−5, U=5 gives 45.