CFG for a powers followed by even b powers

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← 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.

← RGPV CS-501 Theory of Computation May 2023 Solved Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion