by wfunction · 10y ago · 0 comments
I believe you mean NFA to DFA.
> [...] would require O(n^2) in that case
I believe you mean O(2^n). https://en.wikipedia.org/wiki/Powerset_construction#Complexi...
This isn't really a problem if you incur that cost only once by having the regex compiled when the script is parsed. However, idiomatic JS usually includes regex literals in the closure where it is used - decreasing performance, code reuse and clarity. Why? Probably for the same reasons that regex is being used in the first place.
> I believe you mean NFA to DFA.
Yes, you're right. Whoops :P.
> > [...] would require O(n^2) in that case
> I believe you mean O(2^n).
Ah yes, I forgot that you could chain epsilon edges. Fair enough.