(aa+b)* to NFA and DFA, step by step

Worked example: find the language of r = (aa+b)* (strings where every block of a's has even length, so the a's always come in pairs), build an NFA, and convert it to a DFA with the subset construction, one step at a time.

The question

Let r = (aa+b)* 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

Strings where every block of a's has even length, so the a's always come in pairs.

L = { w ∈ {a, b}* : every block of consecutive a's has even length }

In L: λ, aab, baaaab. Not in L: a, aba, aaa.

Part 2 · An NFA

Start with the states. q0 is the start state (the arrow coming in), and q0 is accepting (double circle): finishing there means yes.

Arrows out of q0: on a → q1; on b → q0.

Arrows out of q1: on a → q0.

q0 means "no a waiting for its pair". Reading a moves to q1, and the second a closes the pair. A b in the middle of a pair has no arrow from q1. 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.