automaton algorithms