 The presentation of the algorithm for NFAs below follows Gross and Yellen (2004).Given a nondeterministic finite automaton "M" = ("Q", Σ, δ, "q"0, "F"), with "Q" = { "q"0...,"q""n" } its set of states, the algorithm computes 
Here, "going through a state" means entering "and" leaving it, so both "i" and "j" may be higher than "k", but no intermediate state may.Each set "R" is represented by a regular expression; the algorithm computes them step by step for "k" = -1, 0, ..., "n".