Skip to content
GATEiit

GATE CSE 2023 Q60: Value of 10#011 under a binary-fraction translation scheme

Question

Consider the syntax directed translation given by the following grammar and semantic rules. Here NN, II, FF and BB are non-terminals. NN is the starting non-terminal, and #, 0\mathbf{0} and 1\mathbf{1} are lexical tokens corresponding to input letters “#”, “0” and “1”, respectively. X.valX.val denotes the synthesized attribute (a numeric value) associated with a non-terminal XX. I1I_1 and F1F_1 denote occurrences of II and FF on the right hand side of a production, respectively. For the tokens 0\mathbf{0} and 1\mathbf{1}, 0.val=0\mathbf{0}.val = 0 and 1.val=1\mathbf{1}.val = 1.

N→I # FN.val=I.val+F.valI→I1 BI.val=(2 I1.val)+B.valI→BI.val=B.valF→B F1F.val=12(B.val+F1.val)F→BF.val=12B.valB→0B.val=0.valB→1B.val=1.val\begin{array}{lll} N \to I \,\#\, F & & N.val = I.val + F.val \\ I \to I_1\, B & & I.val = (2\, I_1.val) + B.val \\ I \to B & & I.val = B.val \\ F \to B\, F_1 & & F.val = \frac{1}{2}(B.val + F_1.val) \\ F \to B & & F.val = \frac{1}{2} B.val \\ B \to \mathbf{0} & & B.val = \mathbf{0}.val \\ B \to \mathbf{1} & & B.val = \mathbf{1}.val \end{array}

The value computed by the translation scheme for the input string

10#01110\#011

is _______. (Rounded off to three decimal places)

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 2.374 to 2.376 (official GATE 2023 final answer key)

Concept used: The scheme reads a binary number with an integer part and a fractional part.

First step: Evaluate II for '10' (binary integer) and FF for '011' from the rightmost bit inward.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2023 CS question paper and final answer key, organised by IIT Kanpur. Question paper · Answer key