What are good techniques for creating a DFA state diagram given a set of accepted/rejected strings?

114 Views Asked by At

I am having trouble coming up with solutions and I think its because I am not approaching these problems in the correct manner even though I understand what a DFA is. For those of you who do well with creating state diagrams, how do you approach these problems?

I guess more specifically:

Is there a systematic way of determining what a state diagram should look like given a few strings the machine should accept as well as some strings it rejects?

Edit: Since this got a bad rep, I am going to put an example to be more clear:

What would a DFA look like for a problem like this?

Lb = { w | w’s decimal equivalent is divisible by 6 }

2

There are 2 best solutions below

1
On BEST ANSWER

For your example of decimal strings divisible by $6$, consider the residue modulo $6$ of what has been read as the state $q$; adding a new digit $d$ gives state $(10 q + d) \bmod 6$, which is easy to compute. Might need to spice up with a starting state to avoid strings starting with $0$, and make the state $0$ accepting. This can obviously be generalized to other bases and moduli.

0
On

The answer is unfortunately negative. You are trying to determine some language $L$. If you just know that a finite set of words $F$ is contained in $L$ and that another finite set of words $G$ (disjoint from $F$) is contained in the complement of $L$, then $L$ could be any language of the form $F \cup H$, where $H \cap G = \emptyset$. Thus this information is definitely not sufficient to determine a state diagram.