a* + b* to NFA and DFA, step by step
Worked example: find the language of r = a* + b* (strings made only of a's, or only of b's. The empty string λ counts too), build an NFA, and convert it to a DFA with the subset construction, one step at a time.
The question
Let r = a* + 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 made only of a's, or only of b's. The empty string λ counts too.
L = { aⁿ, bⁿ : n ≥ 0 }
In L: λ, aaa, bb. Not in L: ab, ba, aab.
Part 2 · An NFA
Start with the states. q0 is the start state (the arrow coming in), and q0, q1, q2 are accepting (double circle): finishing there means yes.
Arrows out of q0: on a → q1; on b → q2.
Arrows out of q1: on a → q1.
Arrows out of q2: on b → q2.
The + means OR, so the machine splits into two branches right at the start: one that only reads a's, one that only reads b's. Once a branch is chosen, the other letter has nowhere to go. 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.