I am studying for tomorrows exam and I have checked many tutorials telling how to convert NFA to Regex but I can't seem to confirm my answers. Following the tutorials, I solved that NFA
My solution was:
aba
Am I correct?
I am studying for tomorrows exam and I have checked many tutorials telling how to convert NFA to Regex but I can't seem to confirm my answers. Following the tutorials, I solved that NFA
My solution was:
aba
Am I correct?
Your answer a*ba*
is Correct. I can drive your answer from NFA
in given image as follows:
There is a self loop on start state q0 with label a
. So there can be any number of a
s are possible at initial (prefix) including null ^
in RE. So Regular Expression(RE) start with a*
.
You need only one b
to reach to final state. Actually for an accepting string; there must be at-least one b
in string of a
and b
. So RE a*b
to reach to either q1 or q2. Both are final states.
Once you reach to a final state (q1 or q2). No other b
is possible in string (there is no outgoing edge for b
from q1 and q2).
Only symbol is a
can be possible at q1 and q2. Also for, a
at q1 or at q2 move switch between q1 , q2 and both are final. So after symbol b
any number of a
s can be in suffix. (So string ends with a*
).
And RE is a*ba*
.
Also, its DFA is as follows:
DFA:
======
a- a-
|| ||
▼| ▼|
--►(q0)---b---►((q1))
a* b a* :RE
====
Any number of a
s at q0
that is: a*
once you get b
you can switch to final state q1
: b
at final state any number of a
is possible: a*
And its a Minimized DFA!
Here is some more interesting answer by me on FAs
and REs
, I believe will be useful to you:
(AB)* = A*B*?
That answer is correct, in that both of the following are true:
However, I can't check your work because you haven't posted any.