Professional Documents
Culture Documents
CFG
CFG
DERIVATIONS TREE
Derivation tree or Parse tree is an ordered rooted tree that graphically represents the
semantic information of strings derived from a CFG
2 Types:
1. Left derivation
2. Right derivation
Q1: S0B
A1AA | €
B0AA
Q2: SaAS | aSS | €
ASbA | ba
Q3: G= S0A | 1B
A 0AA | 1S | 1
B 1BB | 0S | 0
AMBIGUITY
A Grammar is said to be Ambiguous if there exists 2 or more derivation tree for a string.
(2 / more left derivation trees)
Q1: Check whether the grammar below is ambiguous or not for the string a + a * b.
SS + S | S * S | a | b
Q2: Check whether the grammar below is ambiguous or not. (Use your own string-
ex: 001101)
G= S0A | 1B
A 0AA | 1S | 1
B 1BB | 0S | 0