

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solution to a homework problem on deriving left-most and right-most derivations from an ambiguous grammar. It includes the given problem statement, the steps to derive the two distinct derivations, and the explanation of why these derivations indicate ambiguity.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Solution for HW Q1.1) S -> 0 | 1 | 0A0 | 1A A -> 0A | 1A | e Q1.2) S -> 0A | 1A A -> 00A | 01A | 10A | 11A | e Q2) A -> BAB | B | e B -> 00 | e Step1) add start symbol A0 -> A A -> BAB | B | e B -> 00 | e Step2)
A0 -> B(B1) | 00 | AB | BA | BB | e A -> B(B1) | 00 | AB | BA | BB B -> 00 B1 -> AB
A0 -> B(B1) | CC | AB | BA | BB | e A -> B(B1) | CC | AB | BA | BB B -> CC B1 -> AB C -> 0 Common mistakes include missing BB, missing e, missing ‘C->0’. Q3. left-most derivation S => aB => aaBB => aaaBBB => aaabBB => aaabbB => aaabbaBB => aaabbabB => aaabbabbS => aaabbabbbA => aaabbabbba Right-most derivation S => aB => aaBB => aaBaBB => aaBaBbS => aaBaBbbA => aaBaBbba => aaBabbba => aaaBBabbba => aaaBbabbba => aaabbabbba (Note that these two derivations are derived from one identical parse tree. You cannot claim that this grammar is ambiguous just because of these two derivations.) Another left-most derivation S => aB => aaBB => aaaBBB => aaabSBB => aaabbABB => aaabbaBB => aaabbabB => aaabbabbS => aaabbabbbA => aaabbabbba