Converting RE to NFA -


which 1 correct way show re union 0+1? saw 2 ways think both correct. if both correct why complicate things?

enter image description here

they both correct, stated.

the first 1 looks generated using set of standard rules -- in case, it's overkill (and looks silly), in more complicated cases it's easier follow easy rules hold whole thing in head , write equivalent nfa scratch.

in general, nfa can rewritten such has single final state (obviously there's 1 start state).

then, 2 nfas in form can combined in such way language accept when combined union of languages accept individually -- corresponds or (+) in regular expression. combine nfas in way, create new node act start state , connect ε-transitions start states of 2 nfas.

then, in order neatly end nfa in single final state (so can use nfa recursively other unions if want), create node serve unified final state , ε-connect old final states (which lose final status) it.

using general rules above, it's easy arrive @ first diagram (two nfas unioned together, first matching 0, other 1) -- second easy arrive @ via common sense since it's such simple regex ;-)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -