top | item 25874571

(no title)

danmg | 5 years ago

Is this really DFA-less? Isn't the look-back table you construct just encoding the DFA?

discuss

order

Jtsummers|5 years ago

It is and it isn't. The DFA is not deliberately constructed, it's more a "happy accident". A renaming/reframing of the `seen` variable would make it obvious that what is constructed is a manually conceived DFA. As presented, `seen` is "how many characters have we seen of the target string?". Reframing it as "There exists a state for each character in the target, `seen` represents which of these states we are presently in" makes it clear that it is a DFA. But as constructed it's an accidental DFA, rather than a deliberate one.