Question: Build an FA that accepts only those words that do not end with ba. I want to Draw DFA for this problem but I don't understand I to do it please help me to draw this
-
What is it about the problem that's giving you trouble? Do you know how to make a DFA for a language that does end in "ba"? If so, how can you modify it to match its inverse? – Welbog Apr 22 '19 at 13:42
3 Answers
Steps:
- Draw DFA which ends with "ba".
- Invert the states i.e.
- Make the final states, non final.
- Non final states, final states
IMAGE: DFA of strings not ending with "ba":

- 2,917
- 23
- 46
- 68

- 66
- 1
- 4
RE for a language that do not end on ba
is (a+b)*(aa+bb+ab)
here language either ends on aa
or bb
or ab
to make DFA from RE you can use this hope it would proved helpful for you https://cyberzhg.github.io/toolbox/nfa2dfa
in this given DFA ..it is accepting strings with length 2 or greater than 2 but not ending on ba

- 607
- 1
- 5
- 16
-
-
sure gona edit my answer..now check ..now it definetly accepts the required strings – sabeen kanwal Apr 24 '19 at 13:31
-
Am I to understand that C0 and C1 are accepting and C0 is initial? If so, I'm still not convinced this is right. The string "ba" itself can lead to either state C0 or C2, so neither of those states can be accepting; but the empty string is in the language, so C0 must be accepting. Also, this is an NFA, not a DFA. – Patrick87 Apr 24 '19 at 13:38
-
yes C0 is both (final and initial ) because epsilon can be part of this language – sabeen kanwal Apr 24 '19 at 13:42
-
But then ba is accepted by taking the self-loop transition twice. You labeled it with a | b meaning either is allowed. – Patrick87 Apr 24 '19 at 13:48
We need to keep track of whether we have seen substrings of ba and if we see the whole thing, make sure we're not in an accepting state at the time.
----->(q0)--b-->(q1)--a-->(q2)
Here, (q0) is accepting, (q1) is accepting and (q2) is not accepting. (q0) corresponds to having seen no part of the string ba, state (q1) to having seen the first symbol, and (q2) to having seen the whole thing. The missing transitions should therefore be:
- q0 to q0 on symbol a, since if we haven't started seeing ba, a is no help; we needed a b
- q1 to q1 on symbol b, since if we see b we have always at least seen the first symbol in ba
- q2 to q0 on symbol a and to q1 on symbol b, for the above reasons.
The whole DFA looks like this:
/--|--b----\
b | |
| V |
----->(q0)--b-->(q1)--a-->(q2)
| ^ |
a | |
\--|-----------------/

- 27,682
- 3
- 38
- 73