DFA that accepts either ab or ba as substring?

  • Topic: Comp Sci 
  • Thread starter shivajikobardan
  • Start date
  • Tags Tags
    Computation Dfa
1 reply · 6K views · last reply
shivajikobardan
Messages
637
Reaction score
54
Homework Statement
I need to create a DFA that contains substrings either ab or ba
Relevant Equations
Deterministic finite automata no equations
Attempt at solution-:

DFA diagram with start state branching on a and b into two paths; the a path loops on a, goes on b to an accepting state looping on a,b; the b path loops on b, goes on a to an accepting state looping on a,b.

Now this dfa will also accept abba which in my inituition it should not accept. But it does accept it. What is going here? Please guide
 
The English language statement "contains either the substrings ab or ba" is the issue. If you read this as an "inclusive or" then your DFA looks okay. If you read it as an "exclusive or" then it is not okay. Since you are a student and you recognize this potential ambiguity, figure out the "exclusive or" case. Submit both variations and your professor will be delighted!

Is the alphabet { a, b } ?
 
Last edited: