b*ab*ab* to NFA and DFA, step by step
Worked example: find the language of r = b*ab*ab* (all strings with exactly two a's (any number of b's around them)), build an NFA, and convert it to a DFA with the subset construction, one step at a time.
The question
Let r = b*ab*ab* be a regular expression over the alphabet Σ = {a, b}.
Part 1: Find the language L(r). Part 2: Construct an NFA that accepts L(r). Part 3: Convert your NFA to a DFA using the subset construction, and draw the final DFA.
Part 1 · The language
All strings with exactly two a's (any number of b's around them).
L = { w ∈ {a, b}* : w has exactly two a's }
In L: aa, baba, abbab. Not in L: a, aaa, bab.
Part 2 · An NFA
Start with the states. q0 is the start state (the arrow coming in), and q2 is accepting (double circle): finishing there means yes.
Arrows out of q0: on a → q1; on b → q0.
Arrows out of q1: on a → q2; on b → q1.
Arrows out of q2: on b → q2.
Each state remembers how many a's you have read so far: 0, 1 or 2. Every b* is a loop. A third a has no arrow, so that path dies. Your NFA may look different and still be correct: check it on the strings from Part 1.
Part 3 · NFA to DFA
The subset construction, one move at a time, and a check of the final DFA on strings from Part 1, with a free account.