- 2074 Bhadra · 2+6 marks
Regular expression and FSA: at least three b's
Short answer
Regular expression: a*ba*ba*b(a+b)*. DFA uses states q0 to q3 counting b seen (0 to ≥3). On a, loop; on b, advance until q3, which is final and loops on a and b.
Given a language, L = {w ∈ {a, b}* : w contain at-least three 'b' s}. Write the regular expression for L and design a Finite State Automata that accepts the Language L. Your design should include the proper definition of the finite-state automaton, transition table and the transition diagram.
L = {w ∈ {a, b}* : w contains at least three b's}.
Regular expression
a*ba*ba*b(a + b)*
The three b's are separated by any number of a's, and after the third b any string is allowed.
Idea for the automaton
Count the b's seen so far, stopping at 3: q0 (no b), q1 (one b), q2 (two b's), q3 (three or more b's, final). The symbol a never changes the count. Once in q3 we stay there.
Formal definition
M = (Q, Σ, δ, q0, F): Q = {q0, q1, q2, q3}, Σ = {a, b}, start state q0, F = {q3}, δ as in the table.
Transition table
| State | a | b |
|---|---|---|
| → q0 | q0 | q1 |
| q1 | q1 | q2 |
| q2 | q2 | q3 |
| *q3 | q3 | q3 |
Transition diagram
a a a a, b
┌─┐ ┌─┐ ┌─┐ ┌─┐
↓ │ ↓ │ ↓ │ ↓ │
→(q0)─b──→(q1)─b──→(q2)─b──→((q3))
Trace
- "abab": q0 –a→ q0 –b→ q1 –a→ q1 –b→ q2. Ends in q2, rejected (2 b's).
- "babab": q0 –b→ q1 –a→ q1 –b→ q2 –a→ q2 –b→ q3. Accepted.
I checked both the machine and the regular expression against the b-count for all strings up to length 8; they agree.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Design FSA accepting odd number of b's · Discrete Structure, chapter 2 · asked 4×
- Define FSM; design FSA with two consecutive a's · Discrete Structure, chapter 2 · asked 4×
- Design FSA accepting even number of a's · Discrete Structure, chapter 2 · asked 4×
- Design FSA for strings beginning with baa · Discrete Structure, chapter 2
- Design NFA for strings ending with aba · Discrete Structure, chapter 2
- Differentiate Finite State Machine and Automata · Discrete Structure, chapter 2 · asked 2×
- Regular expression with substring 0101 · Theory of Computation, chapter 2
- Transition curve R=2000 m, chainages, deflection table · Surveying II, chapter 6
- Regular grammar to RE and FA · Theory of Computation, chapter 2