← RGPV CS-501 Theory of Computation May 2023 Solved Paper
Question
Design a CFG for L(G)={aⁱb²ʲ | i≥0} (condition as printed).
Asked in: CS-501 | May 2023 | 5(a)(ii)
Answer
Assume i,j≥0, as the paper explicitly bounds i but does not specify j. Use S→aS|B and B→bbB|ε. The first phase generates arbitrary a symbols and the second generates b symbols in pairs.
Example: S⇒aS⇒aaS⇒aaB⇒aabbB⇒aabbbbB⇒aabbbb. Each derivation has all a symbols before b symbols and an even b count. Conversely any i,j≥0 can be generated by applying the first recursive rule i times and the second j times. If j must be positive, replace B→bbB|ε with B→bbB|bb.
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion