You are on page 1of 1

CONTEXT FREE GRAMMER

CONTEXT FREE LANGUAGE (CFG)


 Language generated from the CFG  CONTEXT FREE LANGUAGE
Q1: Verify whether the grammar S0B | 1A
A0 | 0S | 1AA | €
B1 | 1S | 0BB
generates the string 00110101
Q2: Verify whether the grammar SaAb
A aAb | €

generates the string aabbb

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: S0B
A1AA | €
B0AA
Q2: SaAS | aSS | €
ASbA | ba

Q3: G= S0A | 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.
SS + S | S * S | a | b
Q2: Check whether the grammar below is ambiguous or not. (Use your own string-
ex: 001101)
G= S0A | 1B
A 0AA | 1S | 1
B 1BB | 0S | 0

You might also like