I cannot solve this problem, if anyone can solve this problem.
my problem is L = {w ∈ {a, b}*, Na(w) mod 2 = 1}
I cannot solve this problem, if anyone can solve this problem.
my problem is L = {w ∈ {a, b}*, Na(w) mod 2 = 1}
If you're stuck writing a regular expression but know how to make the DFA, do that first, then write some equations and solve for the regular expression. A DFA seems easy here:
/---a---\
| |
V |
---->q0--a-->q1
/ ^ / ^
/ | / |
\--/ \--/
b b
Here, q1 is accepting. We get some equations from this:
(q0) = e + (q0)b + (q1)a
(q1) = (q0)a + (q1)b
We want to solve for (q1). Let's remove the self reference in the equation for (q0):
(q0) = e + (q0)b + (q1)a
= (e + (q1)a) + (q0)b
= (e + (q1)a)b*
Now we can substitute in the equation for (q1):
(q1) = (q0)a + (q1)b
= [(e + (q1)a)b*]a + (q1)b
Distributing and rearranging:
(q1) = [(e + (q1)a)b*]a + (q1)b
= (e + (q1)a)b*a + (q1)b
= b*a + (q1)ab*a + (q1)b
= b*a + (q1)(ab*a + b)
Now we can easily remove the self-reference from this equation:
(q1) = b*a + (q1)(ab*a + b)
= b*a(ab*a + b)*
We can observe: