Regular expression for all strings starts with b and ends with bba is:

2025

Regular expression for all strings starts with b and ends with bba is:

Answer: C. b(a+b)*bbaConcept: A regular expression describes a language using three basic operations: concatenation (writing symbols or sub-expressions one after another), union…

  1. A.

    aba*b*bba

  2. B.

    ab(ab)*bba

  3. C.

    b(a+b)*bba

  4. D.

    All of the mentioned

Attempted by 10 students.

Show answer & explanation

Correct answer: C

Concept: A regular expression describes a language using three basic operations: concatenation (writing symbols or sub-expressions one after another), union (the + operator, choosing between alternatives), and the Kleene star (the * operator, zero or more repetitions of whatever it follows). To build an expression for "all strings that start with b and end with bba", the expression must fix the very first symbol as a literal b, allow completely unrestricted content in between, and fix the last three symbols as exactly bba - giving the general shape b(a+b)*bba, where (a+b)* denotes any string at all over the alphabet {a, b}, including the empty string.

Application:

  • aba*b*bba opens with the literal symbol a before any star or union is applied, so every string this expression can generate begins with a - it can never satisfy the requirement of starting with b, no matter what follows.

  • ab(ab)*bba also opens with the fixed sequence a, b in that order - the (ab)* group only repeats a pattern that already starts with a, so this expression too generates only strings beginning with a.

  • b(a+b)*bba opens with the literal symbol b, then (a+b)* freely generates any combination of a and b of any length (including none), and the expression closes with the fixed literal bba - so every string it produces necessarily starts with b and necessarily ends with bba, matching the required language for every such string of length four or more (see the boundary-case note below).

  • Since two of the expressions above are ruled out at their very first symbol, they cannot represent the required language - so a choice claiming every listed expression works is also incorrect.

Cross-check: Checking this against b(a+b)*bba confirms the pattern: taking the leading b, an empty middle segment, and the trailing bba gives bbba, which starts with b and ends in bba. Taking the leading b, middle segment ab, and the trailing bba gives babbba, which again starts with b and ends in bba. No string produced by the other two expressions can ever start with b, since their very first symbol is permanently fixed as a.

Result: The expression that fixes the leading symbol as b, allows unrestricted content through (a+b)*, and fixes the trailing three symbols as bba is the correct construction for the language of all strings starting with b and ending in bba, for every such string of length four or more. (The single 3-character string "bba" is a degenerate boundary case where the required leading b and the required trailing bba trivially overlap into one symbol; this boundary case is outside the standard prefix-plus-suffix construction technique this question is testing, which is why b(a+b)*bba remains the expected construction here.)

Explore the full course: Isro

Loading lesson…