wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

If G is a context-free grammar and w is a string of length n in L(G), how long is a derivation of w in G, if G is in Chomsky normal form?

Open in App
Solution

A context-free grammar G is Chomsky normal form if all productions are in one of two simple form, either:
1. A BC where A,B and C are variables,or
2. A a where A is a variable and a is terminal.
So, for any string of length n first prodcution of type ABC is used n-1 times to produce sentential form of length n containing only variables and then each variable is replaced by a terminal using productions of type Aa, n times.
So the length of derivation to generate a string w of length n in CNF is n+n-1 = 2n-1.
Example :
S XY
Y XZ
X a
Z b
Toderive the string "aab" by using above CNF
S XY
aY
zXZ
aaZ
aab
It requires 5 steps
2|aab|1=2×31=5

flag
Suggest Corrections
thumbs-up
2
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Is Light a Traveler?
Watch in App
Join BYJU'S Learning Program
CrossIcon