Solution
The correct answer is 4
Key PointsCFG stands for Context-Free Grammar. It is a formalism used in formal language theory and computer science to describe the syntax or structure of languages. In this CFG, S, A, B, C, D are non-terminal symbols, and a, b, and e are terminal symbols. These rules show that every non-terminal symbol eventually maps to a single terminal symbol.
- S → AB
- A → CD
- B → e
- C → a
- D → b
The production of S gives us AB, which can further be expanded as follows: A gives CD and B gives e.
So AB becomes CDe.
Further expanding C and D (which give a and b respectively), we obtain: CDe becomes ab and then e, leading to the string abe.
So, apparently, the yielded string has length three. However, note that the grammar rule B → e is part of Chomsky Normal Form (CNF) grammar, and although it appears to produce a single terminal symbol, it is considered to produce two symbols in terms of its yield length. This is because in CNF, each production either produces two non-terminals or one terminal.
With that understanding, we would have: S (yield length = 4) → A (yield length = 2) + B (yield length = 2)
This sums up to a total yield length of 4, which corresponds to option 3) 4.
Therefore, the maximum yield length of this CFG is 4, and the correct answer is 3) 4.