0

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?

State Diagram

Updated I modified the diagram in another attempt:

State Diagram v2

Django
  • 1
  • 1
  • 3

3 Answers3

2

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.

Raphael
  • 73,212
  • 30
  • 182
  • 400
1

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.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109
0

This is the correct answer for the specified specification:

Solution

Django
  • 1
  • 1
  • 3