Solution
The correct answer is : option 3
Key Points
Comprehension Recap: The DFA must recognize strings over Σ = {a, b} that satisfy the following:
- They may start and end with any combination of 'a' and 'b'.
- The string must contain the substring 'abb' anywhere within it.
Goal: We want a DFA that detects the presence of 'abb' anywhere, and allows characters before and after it.
Basic Structure of DFA to Accept 'abb':
- q1: Start state, accepts any number of
a or b.
- q2: Transition on
a from q1 (start of "abb").
- q3: Transition on
b from q2 (second symbol).
- q4: Transition on
b from q3 – string "abb" confirmed. This is a final state.
- q4 loops on both
a and b to accept trailing characters.
Option-Wise Analysis:
✅ Option 3 (Correct):

- q1 loops on
a and b – allows any prefix.
- q1 --
a--> q2
- q2 --
b--> q3
- q3 --
b--> q4 (Final State)
- q4 loops on
a and b – accepts suffix after "abb".
✅ This matches the behavior expected: accepts all strings containing "abb" regardless of their prefix or suffix.
Option 1:

- Correct prefix handling (q1 loops on
a, b).
- Transitions toward detecting "abb" are correct.
- However, q4 lacks a loop on
a or b.
❌ This DFA accepts only strings ending at 'abb', and fails if more characters follow.
Option 2:

- q1 does NOT loop on
a or b.
- This means only strings starting with
a are accepted.
- Violates the rule that string can start with any symbol.
❌ Fails to meet the start flexibility requirement.
Option 4:

- Transitions are not consistent with detecting "abb".
- q3 returns back to q1 on
b, preventing reaching a final state on "abb".
❌ Cannot reach accepting state on any valid 'abb' sequence.
Final Answer: Option 3
This DFA fulfills the language requirements: accepts any string containing 'abb', with any combination of 'a' and 'b' before or after it.