GATE Exam  >  GATE Questions  >  Consider the following grammar with correspon... Start Learning for Free
Consider the following grammar with corresponding synthesized attributes.
F→L{F. yal =L. yal }
L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }
L→B{L. len =1,L. val =B. val/ 2}
B→0{B. yal =0}
B→1{B, val =1}
If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?
  • a)
    0.255
  • b)
    0.156
  • c)
    0.465
  • d)
    0.625
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Consider the following grammar with corresponding synthesized attribut...
Given grammar
F→ .L
L→ LB
L →B
B →0
B →1
Input string .101
View all questions of this test
Most Upvoted Answer
Consider the following grammar with corresponding synthesized attribut...
Understanding the Grammar
To evaluate the grammar for the input `.101`, we need to break it down according to the rules provided. The grammar defines how binary fractions are constructed and how their values are calculated.
Step-by-Step Breakdown
1. Input Representation: The input `.101` can be considered as `F -> L` where `L` represents the binary fraction without the leading zero.
2. Deriving L:
- The first rule `L -> LB` applies here.
- The string can be decomposed as:
- For the first `1`: `L -> LB` (where `B -> 1`)
- For the next `0`: `L -> LB` (where `B -> 0`)
- For the last `1`: `L -> B` (where `B -> 1`)
3. Calculating Length and Value:
- For the first `1`:
- `L1.len = 1`, `B.val = 1` => `L.len = L1.len + 1 = 2`, `L.val = L1.val + 2 - L.len * B.val = 0 + 2 - 1 * 1 = 1`
- For the `0`:
- `L1.len = 2`, `B.val = 0` => `L.len = 3`, `L.val = 1 + 2 - 2 * 0 = 1`
- For the last `1`:
- `B.val = 1` => `L.len = 4`, `L.val = 1 + 2 - 3 * 1 = 0`
4. Final Calculation:
- The total value of the binary fraction is computed:
- For each `1`, we add `2^(-position)`, which results in:
- `1 * 2^(-1) + 0 * 2^(-2) + 1 * 2^(-3) = 0.5 + 0 + 0.125 = 0.625`.
Conclusion
Thus, the value of `F.val` for the input `.101` evaluates to 0.625, confirming that the correct answer is option D.
Explore Courses for GATE exam

Similar GATE Doubts

Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer?
Question Description
Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer?.
Solutions for Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer?, a detailed solution for Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the following grammar with corresponding synthesized attributes.F→L{F. yal =L. yal }L→LB{ L. len =L1 . len +1, L. val =L1 . val +2 -Llen × B. val }L→B{L. len =1,L. val =B. val/ 2}B→0{B. yal =0}B→1{B, val =1}If “F.val” gives the value of the binary fraction generated by F in the above grammar then that will be the value of F.val on input .101?a)0.255b)0.156c)0.465d)0.625Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev