Algorithm for deterministic recognition of FSAs