I've made the following diagram to accept a, ad, abc, abd but I don't it to accept e, abcd, how can I limit that?
Updated I modified the diagram in another attempt:
I've made the following diagram to accept a, ad, abc, abd but I don't it to accept e, abcd, how can I limit that?
Updated I modified the diagram in another attempt:
Your automaton has loops so it accepts an infinite language.
For finite languages $\{w_1, \dots, w_n\}$, it's easy to write them as regular expression
$\qquad w_1 \mid \ldots \mid w_k$
and apply Thompson's construction. If the resulting automaton is too ugly for your taste, determinize and minimize according to the canonical textbooks.
Warning: Determinizing automata for finite languages can blow up automaton size exponentially.
Note how this approach scales neatly to more concise representations of finite languages and even infinite languages -- all you need is a regular expression. Or any other formalism equivalent to finite automata, as the proofs of equivalence are usually constructive.
Just make an automaton that looks like a tree, for each state splitting into the possible letters.
In data structure terminology such a tree with leters on edges is called a trie, as in re-trie-val.