Regular expression for exactly two a symbols

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

Share on WhatsApp

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Question

Obtain a regular expression for all strings over Σ = {a,b} containing exactly two a symbols.

Asked in: CS-501 | November 2019 | 1(b)(i)

Answer

The required expression is b*ab*ab*

The three b* factors allow any number of b symbols before, between and after the two mandatory a symbols. No other a can be generated. Conversely, every string containing exactly two a symbols can be split at those occurrences into three blocks consisting only of b symbols.

Examples accepted: aa, aba, bbaabb. Examples rejected: ε, a, aaa, bbb.

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Discussion

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

Sign in to participate in the discussion.

Join the discussion